diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java b/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java index 86e90a4c8..51bd9c45b 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java @@ -1,19 +1,21 @@ /* * * * - * * * Copyright 2019-2020 the original author or authors. * * * - * * * Licensed under the Apache License, Version 2.0 (the "License"); - * * * you may not use this file except in compliance with the License. - * * * You may obtain a copy of the License at + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. * * * - * * * https://www.apache.org/licenses/LICENSE-2.0 - * * * - * * * Unless required by applicable law or agreed to in writing, software - * * * distributed under the License is distributed on an "AS IS" BASIS, - * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * * See the License for the specific language governing permissions and - * * * limitations under the License. * * * */ @@ -52,9 +54,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature; import io.swagger.v3.core.filter.SpecFilter; -import io.swagger.v3.core.util.Json; import io.swagger.v3.core.util.ReflectionUtils; -import io.swagger.v3.core.util.Yaml; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.callbacks.Callback; import io.swagger.v3.oas.annotations.enums.ParameterIn; @@ -74,7 +74,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springdoc.api.mixins.SortedOpenAPIMixin; +import org.springdoc.api.mixins.SortedOpenAPIMixin31; import org.springdoc.api.mixins.SortedSchemaMixin; +import org.springdoc.api.mixins.SortedSchemaMixin31; import org.springdoc.core.AbstractRequestService; import org.springdoc.core.GenericParameterService; import org.springdoc.core.GenericResponseService; @@ -82,6 +84,7 @@ import org.springdoc.core.OpenAPIService; import org.springdoc.core.OperationService; import org.springdoc.core.SpringDocConfigProperties; +import org.springdoc.core.SpringDocConfigProperties.ApiDocs.OpenApiVersion; import org.springdoc.core.SpringDocConfigProperties.GroupConfig; import org.springdoc.core.SpringDocProviders; import org.springdoc.core.annotations.RouterOperations; @@ -315,6 +318,8 @@ protected synchronized OpenAPI getOpenApi(Locale locale) { Map findControllerAdvice = openAPIService.getControllerAdviceMap(); // calculate generic responses openApi = openAPIService.getCalculatedOpenAPI(); + if (OpenApiVersion.OPENAPI_3_1 == springDocConfigProperties.getApiDocs().getVersion()) + openApi.openapi(OpenApiVersion.OPENAPI_3_1.getVersion()); if (springDocConfigProperties.isDefaultOverrideWithGenericResponse()) { if (!CollectionUtils.isEmpty(mappingsMap)) findControllerAdvice.putAll(mappingsMap); @@ -341,8 +346,8 @@ protected synchronized OpenAPI getOpenApi(Locale locale) { List servers = openApi.getServers(); List serversCopy = null; try { - serversCopy = Json.mapper() - .readValue(Json.mapper().writeValueAsString(servers), new TypeReference>() {}); + serversCopy = springDocProviders.jsonMapper() + .readValue(springDocProviders.jsonMapper().writeValueAsString(servers), new TypeReference>() {}); } catch (JsonProcessingException e) { LOGGER.warn("Json Processing Exception occurred: {}", e.getMessage()); @@ -610,7 +615,7 @@ protected void calculatePath(RouterOperation routerOperation, Locale locale) { * @param locale the locale */ protected void calculatePath(HandlerMethod handlerMethod, String operationPath, - Set requestMethods,String[] consumes, String[] produces, String[] headers, Locale locale) { + Set requestMethods, String[] consumes, String[] produces, String[] headers, Locale locale) { this.calculatePath(handlerMethod, new RouterOperation(operationPath, requestMethods.toArray(new RequestMethod[requestMethods.size()]), consumes, produces, headers), locale); } @@ -837,7 +842,7 @@ protected Set getDefaultAllowedHttpMethods() { * @return the operation */ protected Operation customiseOperation(Operation operation, HandlerMethod handlerMethod) { - if(operationCustomizers.isPresent()){ + if (operationCustomizers.isPresent()) { List operationCustomizerList = operationCustomizers.get(); for (OperationCustomizer operationCustomizer : operationCustomizerList) operation = operationCustomizer.customize(operation, handlerMethod); @@ -1172,7 +1177,7 @@ protected void initOpenAPIBuilder(Locale locale) { */ protected String writeYamlValue(OpenAPI openAPI) throws JsonProcessingException { String result; - ObjectMapper objectMapper = Yaml.mapper(); + ObjectMapper objectMapper = springDocProviders.yamlMapper(); if (springDocConfigProperties.isWriterWithOrderByKeys()) sortOutput(objectMapper); YAMLFactory factory = (YAMLFactory) objectMapper.getFactory(); @@ -1243,7 +1248,7 @@ protected boolean isActuatorRestController(String operationPath, HandlerMethod h */ protected String writeJsonValue(OpenAPI openAPI) throws JsonProcessingException { String result; - ObjectMapper objectMapper = Json.mapper(); + ObjectMapper objectMapper = springDocProviders.jsonMapper(); if (springDocConfigProperties.isWriterWithOrderByKeys()) sortOutput(objectMapper); if (!springDocConfigProperties.isWriterWithDefaultPrettyPrinter()) @@ -1322,8 +1327,13 @@ enum ConditionType { private void sortOutput(ObjectMapper objectMapper) { objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); - objectMapper.addMixIn(OpenAPI.class, SortedOpenAPIMixin.class); - objectMapper.addMixIn(Schema.class, SortedSchemaMixin.class); + if (OpenApiVersion.OPENAPI_3_1 == springDocConfigProperties.getApiDocs().getVersion()){ + objectMapper.addMixIn(OpenAPI.class, SortedOpenAPIMixin31.class); + objectMapper.addMixIn(Schema.class, SortedSchemaMixin31.class); + } else { + objectMapper.addMixIn(OpenAPI.class, SortedOpenAPIMixin.class); + objectMapper.addMixIn(Schema.class, SortedSchemaMixin.class); + } } /** diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/api/mixins/SortedOpenAPIMixin31.java b/springdoc-openapi-common/src/main/java/org/springdoc/api/mixins/SortedOpenAPIMixin31.java new file mode 100644 index 000000000..014654733 --- /dev/null +++ b/springdoc-openapi-common/src/main/java/org/springdoc/api/mixins/SortedOpenAPIMixin31.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES 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.api.mixins; + +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import io.swagger.v3.core.jackson.PathsSerializer; +import io.swagger.v3.oas.models.Paths; + +/** + * @author bnasslashen + */ +@JsonPropertyOrder(value = {"openapi", "info", "externalDocs", "servers", "security", "tags", "paths", "components", "webhooks"}, alphabetic = true) +public interface SortedOpenAPIMixin31 { + + @JsonAnyGetter + @JsonInclude(value = Include.ALWAYS) + @JsonPropertyOrder(alphabetic = true) + Map getExtensions(); + + @JsonAnySetter + void addExtension(String name, Object value); + + @JsonSerialize(using = PathsSerializer.class) + Paths getPaths(); + +} \ No newline at end of file diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/api/mixins/SortedSchemaMixin31.java b/springdoc-openapi-common/src/main/java/org/springdoc/api/mixins/SortedSchemaMixin31.java new file mode 100644 index 000000000..611c0e5ef --- /dev/null +++ b/springdoc-openapi-common/src/main/java/org/springdoc/api/mixins/SortedSchemaMixin31.java @@ -0,0 +1,82 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES 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.api.mixins; + +import java.math.BigDecimal; +import java.util.Map; +import java.util.Set; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +/** + * @author bnasslashen + */ +@JsonPropertyOrder(value = {"type", "format"}, alphabetic = true) +public interface SortedSchemaMixin31 { + + @JsonAnyGetter + @JsonPropertyOrder(alphabetic = true) + Map getExtensions(); + + @JsonIgnore + Map getJsonSchema(); + + @JsonIgnore + Boolean getNullable(); + + @JsonIgnore + Boolean getExclusiveMinimum(); + + @JsonIgnore + Boolean getExclusiveMaximum(); + + @JsonProperty("exclusiveMinimum") + BigDecimal getExclusiveMinimumValue(); + + @JsonProperty("exclusiveMaximum") + BigDecimal getExclusiveMaximumValue(); + + @JsonIgnore + String getType(); + + @JsonProperty("type") + Set getTypes(); + + @JsonAnySetter + void addExtension(String name, Object value); + + @JsonIgnore + boolean getExampleSetFlag(); + + @JsonInclude(JsonInclude.Include.CUSTOM) + Object getExample(); + + @JsonIgnore + Object getJsonSchemaImpl(); + +} \ No newline at end of file diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/GenericParameterService.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/GenericParameterService.java index c2fc98cd4..d8e09072c 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/GenericParameterService.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/GenericParameterService.java @@ -34,7 +34,6 @@ import com.fasterxml.jackson.annotation.JsonView; import io.swagger.v3.core.util.AnnotationsUtils; -import io.swagger.v3.core.util.Json; import io.swagger.v3.core.util.PrimitiveType; import io.swagger.v3.oas.annotations.enums.Explode; import io.swagger.v3.oas.annotations.media.ExampleObject; @@ -50,6 +49,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springdoc.core.customizers.DelegatingMethodParameterCustomizer; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springdoc.core.providers.WebConversionServiceProvider; import org.springframework.beans.factory.config.BeanExpressionContext; @@ -110,18 +110,26 @@ public class GenericParameterService { */ private ConfigurableBeanFactory configurableBeanFactory; + /** + * The Object mapper provider. + */ + private final ObjectMapperProvider objectMapperProvider; + /** * Instantiates a new Generic parameter builder. * @param propertyResolverUtils the property resolver utils * @param optionalDelegatingMethodParameterCustomizer the optional delegating method parameter customizer - * @param optionalWebConversionServiceProvider + * @param optionalWebConversionServiceProvider the optional web conversion service provider + * @param objectMapperProvider the object mapper provider */ - public GenericParameterService(PropertyResolverUtils propertyResolverUtils, Optional optionalDelegatingMethodParameterCustomizer, Optional optionalWebConversionServiceProvider) { + public GenericParameterService(PropertyResolverUtils propertyResolverUtils, Optional optionalDelegatingMethodParameterCustomizer, + Optional optionalWebConversionServiceProvider, ObjectMapperProvider objectMapperProvider) { this.propertyResolverUtils = propertyResolverUtils; this.optionalDelegatingMethodParameterCustomizer = optionalDelegatingMethodParameterCustomizer; this.optionalWebConversionServiceProvider = optionalWebConversionServiceProvider; this.configurableBeanFactory = propertyResolverUtils.getFactory(); this.expressionContext = (configurableBeanFactory != null ? new BeanExpressionContext(configurableBeanFactory, new RequestScope()) : null); + this.objectMapperProvider = objectMapperProvider; } /** @@ -232,7 +240,7 @@ public Parameter buildParameterFromDoc(io.swagger.v3.oas.annotations.Parameter p parameter.setIn(parameterDoc.in().toString()); if (StringUtils.isNotBlank(parameterDoc.example())) { try { - parameter.setExample(Json.mapper().readTree(parameterDoc.example())); + parameter.setExample(objectMapperProvider.jsonMapper().readTree(parameterDoc.example())); } catch (IOException e) { parameter.setExample(parameterDoc.example()); @@ -294,7 +302,7 @@ private void setSchema(io.swagger.v3.oas.annotations.Parameter parameterDoc, Com schema = AnnotationsUtils.getSchema(parameterDoc.schema(), parameterDoc.array(), true, parameterDoc.array().schema().implementation(), components, jsonView).orElse(null); // default value not set by swagger-core for array ! if (schema != null) { - Object defaultValue = SpringDocAnnotationsUtils.resolveDefaultValue(parameterDoc.array().arraySchema().defaultValue()); + Object defaultValue = SpringDocAnnotationsUtils.resolveDefaultValue(parameterDoc.array().arraySchema().defaultValue(), objectMapperProvider.jsonMapper()); schema.setDefault(defaultValue); } } @@ -524,6 +532,8 @@ public Optional getOptionalWebConversionServicePro /** * Resolve the given annotation-specified value, * potentially containing placeholders and expressions. + * @param value the value + * @return the object */ public Object resolveEmbeddedValuesAndExpressions(String value) { if (this.configurableBeanFactory == null || this.expressionContext == null) { diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocAnnotationsUtils.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocAnnotationsUtils.java index 95e68b156..27f990d50 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocAnnotationsUtils.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocAnnotationsUtils.java @@ -32,11 +32,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonView; +import com.fasterxml.jackson.databind.ObjectMapper; 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.core.util.AnnotationsUtils; -import io.swagger.v3.core.util.Json; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.media.ExampleObject; import io.swagger.v3.oas.models.Components; @@ -376,11 +376,11 @@ private static boolean isArray(io.swagger.v3.oas.annotations.media.Content annot return isArray; } - public static Object resolveDefaultValue(String defaultValueStr) { + public static Object resolveDefaultValue(String defaultValueStr, ObjectMapper objectMapper) { Object defaultValue = null; if (StringUtils.isNotEmpty(defaultValueStr)) { try { - defaultValue = Json.mapper().readTree(defaultValueStr); + defaultValue = objectMapper.readTree(defaultValueStr); } catch (IOException e) { defaultValue = defaultValueStr; diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocConfigProperties.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocConfigProperties.java index 7805b0807..9d889a8ce 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocConfigProperties.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocConfigProperties.java @@ -579,7 +579,7 @@ public void setDefaultProducesMediaType(String defaultProducesMediaType) { * * @return the boolean */ - public Boolean isOverrideWithGenericResponse() { + public boolean isOverrideWithGenericResponse() { return overrideWithGenericResponse != null && overrideWithGenericResponse; } @@ -915,6 +915,11 @@ public static class ApiDocs { */ private Groups groups = new Groups(); + /** + * The OpenAPI version. + */ + private OpenApiVersion version; + /** * Gets path. * @@ -986,8 +991,64 @@ public boolean isResolveSchemaProperties() { public void setResolveSchemaProperties(boolean resolveSchemaProperties) { this.resolveSchemaProperties = resolveSchemaProperties; } + + /** + * Gets version. + * + * @return the version + */ + public OpenApiVersion getVersion() { + return version; + } + + /** + * Sets version. + * + * @param version the version + */ + public void setVersion(OpenApiVersion version) { + this.version = version; + } + + /** + * The enum OpenApiVersion. + */ + public enum OpenApiVersion { + /** + *Openapi 3.0.1 version. + */ + OPENAPI_3_0("3.0.1"), + /** + *Openapi 3.1.0 version. + */ + OPENAPI_3_1("3.1.0"); + + /** + * The Open api version. + */ + private String version; + + /** + * Instantiates a new OpenApiVersion. + * + * @param openApiVersion the open api version + */ + OpenApiVersion(String openApiVersion) { + this.version = openApiVersion; + } + + /** + * Gets open api version. + * + * @return the open api version + */ + public String getVersion() { + return version; + } + } } + /** * The type Groups. * @author bnasslahsen diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocConfiguration.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocConfiguration.java index 508a10300..e65683a2d 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocConfiguration.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocConfiguration.java @@ -58,6 +58,7 @@ import org.springdoc.core.providers.ActuatorProvider; import org.springdoc.core.providers.CloudFunctionProvider; import org.springdoc.core.providers.JavadocProvider; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springdoc.core.providers.RepositoryRestConfigurationProvider; import org.springdoc.core.providers.RepositoryRestResourceProvider; import org.springdoc.core.providers.RouterFunctionProvider; @@ -142,12 +143,13 @@ LocalVariableTableParameterNameDiscoverer localSpringDocParameterNameDiscoverer( /** * Additional models converter additional models converter. * + * @param objectMapperProvider the object mapper provider * @return the additional models converter */ @Bean @Lazy(false) - AdditionalModelsConverter additionalModelsConverter() { - return new AdditionalModelsConverter(); + AdditionalModelsConverter additionalModelsConverter(ObjectMapperProvider objectMapperProvider) { + return new AdditionalModelsConverter(objectMapperProvider); } /** @@ -165,25 +167,27 @@ PropertyCustomizingConverter propertyCustomizingConverter(Optional optionalDelegatingMethodParameterCustomizer, - Optional optionalWebConversionServiceProvider) { + Optional optionalWebConversionServiceProvider, ObjectMapperProvider objectMapperProvider) { return new GenericParameterService(propertyResolverUtils, optionalDelegatingMethodParameterCustomizer, - optionalWebConversionServiceProvider); + optionalWebConversionServiceProvider, objectMapperProvider); } /** @@ -388,14 +396,17 @@ static BeanFactoryPostProcessor springdocBeanFactoryPostProcessor2() { * @param repositoryRestResourceProvider the repository rest resource provider * @param routerFunctionProvider the router function provider * @param springWebProvider the spring web provider + * @param objectMapperProvider the object mapper provider * @return the spring doc providers */ @Bean @ConditionalOnMissingBean @Lazy(false) SpringDocProviders springDocProviders(Optional actuatorProvider, Optional springCloudFunctionProvider, Optional springSecurityOAuth2Provider, - Optional repositoryRestResourceProvider, Optional routerFunctionProvider, Optional springWebProvider) { - return new SpringDocProviders(actuatorProvider, springCloudFunctionProvider, springSecurityOAuth2Provider, repositoryRestResourceProvider, routerFunctionProvider, springWebProvider); + Optional repositoryRestResourceProvider, Optional routerFunctionProvider, + Optional springWebProvider, Optional webConversionServiceProvider, + ObjectMapperProvider objectMapperProvider) { + return new SpringDocProviders(actuatorProvider, springCloudFunctionProvider, springSecurityOAuth2Provider, repositoryRestResourceProvider, routerFunctionProvider, springWebProvider, webConversionServiceProvider, objectMapperProvider); } /** @@ -496,16 +507,17 @@ static class SpringDocPageableConfiguration { /** * Pageable open api converter pageable open api converter. * + * @param objectMapperProvider the object mapper provider * @return the pageable open api converter */ @Bean @ConditionalOnMissingBean @ConditionalOnProperty(name = SPRINGDOC_PAGEABLE_CONVERTER_ENABLED, matchIfMissing = true) @Lazy(false) - PageableOpenAPIConverter pageableOpenAPIConverter() { + PageableOpenAPIConverter pageableOpenAPIConverter(ObjectMapperProvider objectMapperProvider) { getConfig().replaceParameterObjectWithClass(org.springframework.data.domain.Pageable.class, org.springdoc.core.converters.models.Pageable.class) .replaceParameterObjectWithClass(org.springframework.data.domain.PageRequest.class, org.springdoc.core.converters.models.Pageable.class); - return new PageableOpenAPIConverter(); + return new PageableOpenAPIConverter(objectMapperProvider); } /** @@ -572,15 +584,27 @@ static class SpringDocFunctionCatalogConfiguration { * Spring cloud function provider spring cloud function provider. * * @param functionCatalog the function catalog - * @param genericResponseService the generic response service * @param springDocConfigProperties the spring doc config properties * @return the spring cloud function provider */ @Bean @ConditionalOnMissingBean @Lazy(false) - CloudFunctionProvider springCloudFunctionProvider(Optional functionCatalog, GenericResponseService genericResponseService, SpringDocConfigProperties springDocConfigProperties) { - return new SpringCloudFunctionProvider(functionCatalog, genericResponseService, springDocConfigProperties); + CloudFunctionProvider springCloudFunctionProvider(Optional functionCatalog, SpringDocConfigProperties springDocConfigProperties) { + return new SpringCloudFunctionProvider(functionCatalog, springDocConfigProperties); } } + + /** + * Object mapper provider object mapper provider. + * + * @param springDocConfigProperties the spring doc config properties + * @return the object mapper provider + */ + @Bean + @ConditionalOnMissingBean + @Lazy(false) + ObjectMapperProvider objectMapperProvider(SpringDocConfigProperties springDocConfigProperties){ + return new ObjectMapperProvider(springDocConfigProperties); + } } \ No newline at end of file diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocProviders.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocProviders.java index 23d787531..a4b7e6ff7 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocProviders.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocProviders.java @@ -21,12 +21,15 @@ import java.util.Optional; +import com.fasterxml.jackson.databind.ObjectMapper; import org.springdoc.core.providers.ActuatorProvider; import org.springdoc.core.providers.CloudFunctionProvider; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springdoc.core.providers.RepositoryRestResourceProvider; import org.springdoc.core.providers.RouterFunctionProvider; import org.springdoc.core.providers.SecurityOAuth2Provider; import org.springdoc.core.providers.SpringWebProvider; +import org.springdoc.core.providers.WebConversionServiceProvider; /** * The type Spring doc providers. @@ -64,6 +67,16 @@ public class SpringDocProviders { */ private final Optional springWebProvider; + /** + * The Web conversion service. + */ + private final Optional optionalWebConversionServiceProvider; + + /** + * The Object mapper provider. + */ + private final ObjectMapperProvider objectMapperProvider; + /** * Instantiates a new Spring doc providers. * @param actuatorProvider the actuator provider @@ -72,16 +85,22 @@ public class SpringDocProviders { * @param repositoryRestResourceProvider the repository rest resource provider * @param routerFunctionProvider the router function provider * @param springWebProvider the spring web provider + * @param optionalWebConversionServiceProvider the optional web conversion service provider + * @param objectMapperProvider the object mapper provider */ public SpringDocProviders(Optional actuatorProvider, Optional springCloudFunctionProvider, Optional springSecurityOAuth2Provider, Optional repositoryRestResourceProvider, - Optional routerFunctionProvider, Optional springWebProvider) { + Optional routerFunctionProvider, Optional springWebProvider, + Optional optionalWebConversionServiceProvider, + ObjectMapperProvider objectMapperProvider) { this.actuatorProvider = actuatorProvider; this.springCloudFunctionProvider = springCloudFunctionProvider; this.springSecurityOAuth2Provider = springSecurityOAuth2Provider; this.repositoryRestResourceProvider = repositoryRestResourceProvider; this.routerFunctionProvider = routerFunctionProvider; this.springWebProvider = springWebProvider; + this.optionalWebConversionServiceProvider = optionalWebConversionServiceProvider; + this.objectMapperProvider = objectMapperProvider; } /** @@ -137,4 +156,31 @@ public Optional getRouterFunctionProvider() { public Optional getSpringWebProvider() { return springWebProvider; } + + /** + * Gets optional web conversion service provider. + * + * @return the optional web conversion service provider + */ + public Optional getOptionalWebConversionServiceProvider() { + return optionalWebConversionServiceProvider; + } + + /** + * Json mapper object mapper. + * + * @return the object mapper provider + */ + public ObjectMapper jsonMapper() { + return objectMapperProvider.jsonMapper(); + } + + /** + * Yaml mapper object mapper. + * + * @return the object mapper + */ + public ObjectMapper yamlMapper() { + return objectMapperProvider.yamlMapper(); + } } diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/AdditionalModelsConverter.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/AdditionalModelsConverter.java index 9ad46874b..4223bfcac 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/AdditionalModelsConverter.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/AdditionalModelsConverter.java @@ -28,8 +28,8 @@ import io.swagger.v3.core.converter.AnnotatedType; import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.converter.ModelConverterContext; -import io.swagger.v3.core.util.Json; import io.swagger.v3.oas.models.media.Schema; +import org.springdoc.core.providers.ObjectMapperProvider; /** * The type Additional models converter. @@ -52,6 +52,20 @@ public class AdditionalModelsConverter implements ModelConverter { */ private static final Map paramObjectReplacementMap = new HashMap<>(); + /** + * The Spring doc object mapper. + */ + private final ObjectMapperProvider springDocObjectMapper; + + /** + * Instantiates a new Additional models converter. + * + * @param springDocObjectMapper the spring doc object mapper + */ + public AdditionalModelsConverter(ObjectMapperProvider springDocObjectMapper) { + this.springDocObjectMapper = springDocObjectMapper; + } + /** * Replace with class. * @@ -112,7 +126,7 @@ public static void disableReplacement(Class clazz) { */ @Override public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator chain) { - JavaType javaType = Json.mapper().constructType(type.getType()); + JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType()); if (javaType != null) { Class cls = javaType.getRawClass(); if (modelToSchemaMap.containsKey(cls)) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/FileSupportConverter.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/FileSupportConverter.java index c93ffb6ca..5d6ae0432 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/FileSupportConverter.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/FileSupportConverter.java @@ -27,9 +27,9 @@ import io.swagger.v3.core.converter.AnnotatedType; import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.converter.ModelConverterContext; -import io.swagger.v3.core.util.Json; import io.swagger.v3.oas.models.media.FileSchema; import io.swagger.v3.oas.models.media.Schema; +import org.springdoc.core.providers.ObjectMapperProvider; import static org.springdoc.core.GenericParameterService.isFile; @@ -39,9 +39,23 @@ */ public class FileSupportConverter implements ModelConverter { + /** + * The Spring doc object mapper. + */ + private final ObjectMapperProvider springDocObjectMapper; + + /** + * Instantiates a new File support converter. + * + * @param springDocObjectMapper the spring doc object mapper + */ + public FileSupportConverter(ObjectMapperProvider springDocObjectMapper) { + this.springDocObjectMapper = springDocObjectMapper; + } + @Override public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator chain) { - JavaType javaType = Json.mapper().constructType(type.getType()); + JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType()); if (javaType != null) { Class cls = javaType.getRawClass(); if (isFile(cls)) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/PageableOpenAPIConverter.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/PageableOpenAPIConverter.java index 8b2e9e9c2..5a8566b45 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/PageableOpenAPIConverter.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/PageableOpenAPIConverter.java @@ -26,10 +26,10 @@ import io.swagger.v3.core.converter.AnnotatedType; import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.converter.ModelConverterContext; -import io.swagger.v3.core.util.Json; 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; /** * The Pageable Type models converter. @@ -52,6 +52,20 @@ public class PageableOpenAPIConverter implements ModelConverter { */ private static final AnnotatedType PAGEABLE = new AnnotatedType(Pageable.class).resolveAsRef(true); + /** + * The Spring doc object mapper. + */ + private final ObjectMapperProvider springDocObjectMapper; + + /** + * Instantiates a new Pageable open api converter. + * + * @param springDocObjectMapper the spring doc object mapper + */ + public PageableOpenAPIConverter(ObjectMapperProvider springDocObjectMapper) { + this.springDocObjectMapper = springDocObjectMapper; + } + /** * Resolve schema. * @@ -62,7 +76,7 @@ public class PageableOpenAPIConverter implements ModelConverter { */ @Override public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator chain) { - JavaType javaType = Json.mapper().constructType(type.getType()); + JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType()); if (javaType != null) { Class cls = javaType.getRawClass(); if (PAGEABLE_TO_REPLACE.equals(cls.getCanonicalName()) || PAGE_REQUEST_TO_REPLACE.equals(cls.getCanonicalName())) { diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java index c9ecdb07a..7810a10b0 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java @@ -31,15 +31,30 @@ 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.core.util.Json; import io.swagger.v3.oas.models.media.ComposedSchema; import io.swagger.v3.oas.models.media.Schema; +import org.springdoc.core.providers.ObjectMapperProvider; /** * The type Polymorphic model converter. * @author bnasslahsen */ public class PolymorphicModelConverter implements ModelConverter { + + /** + * The Spring doc object mapper. + */ + private final ObjectMapperProvider springDocObjectMapper; + + /** + * Instantiates a new Polymorphic model converter. + * + * @param springDocObjectMapper the spring doc object mapper + */ + public PolymorphicModelConverter(ObjectMapperProvider springDocObjectMapper) { + this.springDocObjectMapper = springDocObjectMapper; + } + @Override public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator chain) { if (chain.hasNext()) { @@ -82,7 +97,7 @@ private Schema composePolymorphicSchema(AnnotatedType type, Schema schema, Colle * @return the boolean */ private boolean isConcreteClass(AnnotatedType type) { - JavaType javaType = Json.mapper().constructType(type.getType()); + JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType()); Class clazz = javaType.getRawClass(); return !Modifier.isAbstract(clazz.getModifiers()) && !clazz.isInterface(); } diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/RequestTypeToIgnoreConverter.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/RequestTypeToIgnoreConverter.java index 7e6513815..b27321d47 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/RequestTypeToIgnoreConverter.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/RequestTypeToIgnoreConverter.java @@ -26,9 +26,9 @@ import io.swagger.v3.core.converter.AnnotatedType; import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.converter.ModelConverterContext; -import io.swagger.v3.core.util.Json; import io.swagger.v3.oas.models.media.Schema; import org.springdoc.core.AbstractRequestService; +import org.springdoc.core.providers.ObjectMapperProvider; /** * The type Request type to ignore converter. @@ -36,10 +36,24 @@ */ public class RequestTypeToIgnoreConverter implements ModelConverter { + /** + * The Spring doc object mapper. + */ + private final ObjectMapperProvider springDocObjectMapper; + + /** + * Instantiates a new Request type to ignore converter. + * + * @param springDocObjectMapper the spring doc object mapper + */ + public RequestTypeToIgnoreConverter(ObjectMapperProvider springDocObjectMapper) { + this.springDocObjectMapper = springDocObjectMapper; + } + @Override public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator chain) { if (type.isSchemaProperty()) { - JavaType javaType = Json.mapper().constructType(type.getType()); + JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType()); Class cls = javaType.getRawClass(); if (AbstractRequestService.isRequestTypeToIgnore(cls)) return null; diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/ResponseSupportConverter.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/ResponseSupportConverter.java index acab1fff3..41b2f20c7 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/ResponseSupportConverter.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/ResponseSupportConverter.java @@ -27,9 +27,9 @@ import io.swagger.v3.core.converter.AnnotatedType; import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.converter.ModelConverterContext; -import io.swagger.v3.core.util.Json; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.StringSchema; +import org.springdoc.core.providers.ObjectMapperProvider; import static org.springdoc.core.converters.ConverterUtils.isFluxTypeWrapper; import static org.springdoc.core.converters.ConverterUtils.isResponseTypeToIgnore; @@ -41,9 +41,23 @@ */ public class ResponseSupportConverter implements ModelConverter { + /** + * The Spring doc object mapper. + */ + private final ObjectMapperProvider springDocObjectMapper; + + /** + * Instantiates a new Response support converter. + * + * @param springDocObjectMapper the spring doc object mapper + */ + public ResponseSupportConverter(ObjectMapperProvider springDocObjectMapper) { + this.springDocObjectMapper = springDocObjectMapper; + } + @Override public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator chain) { - JavaType javaType = Json.mapper().constructType(type.getType()); + JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType()); if (javaType != null) { Class cls = javaType.getRawClass(); if (isResponseTypeWrapper(cls) && !isFluxTypeWrapper(cls)) { diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java new file mode 100644 index 000000000..0d9382193 --- /dev/null +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java @@ -0,0 +1,89 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES 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.providers; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.v3.core.util.Json; +import io.swagger.v3.core.util.Json31; +import io.swagger.v3.core.util.Yaml; +import io.swagger.v3.core.util.Yaml31; +import org.springdoc.core.SpringDocConfigProperties; +import org.springdoc.core.SpringDocConfigProperties.ApiDocs.OpenApiVersion; + +/** + * The type Spring doc object mapper provider. + */ +public class ObjectMapperProvider { + + /** + * The Json mapper. + */ + private final ObjectMapper jsonMapper; + + /** + * The Yaml mapper. + */ + 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(); + yamlMapper = Yaml31.mapper(); + } + else { + jsonMapper = Json.mapper(); + yamlMapper = Yaml.mapper(); + } + } + + /** + * Mapper object mapper. + * + * @return the object mapper + */ + public ObjectMapper jsonMapper() { + return jsonMapper; + } + + /** + * Yaml mapper object mapper. + * + * @return the object mapper + */ + public ObjectMapper yamlMapper() { + return yamlMapper; + } +} diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/providers/SpringCloudFunctionProvider.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/providers/SpringCloudFunctionProvider.java index 609a924d8..467cdfe8d 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/providers/SpringCloudFunctionProvider.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/providers/SpringCloudFunctionProvider.java @@ -51,11 +51,6 @@ public class SpringCloudFunctionProvider implements CloudFunctionProvider, Appli */ private final Optional functionCatalogOptional; - /** - * The Generic response service. - */ - private final GenericResponseService genericResponseService; - /** * The Spring doc config properties. */ @@ -95,17 +90,16 @@ public class SpringCloudFunctionProvider implements CloudFunctionProvider, Appli /** * Instantiates a new Spring cloud function provider. * @param functionCatalogOptional the function catalog - * @param genericResponseService the generic response service * @param springDocConfigProperties the spring doc config properties */ - public SpringCloudFunctionProvider(Optional functionCatalogOptional, GenericResponseService genericResponseService, SpringDocConfigProperties springDocConfigProperties) { + public SpringCloudFunctionProvider(Optional functionCatalogOptional, SpringDocConfigProperties springDocConfigProperties) { this.functionCatalogOptional = functionCatalogOptional; - this.genericResponseService = genericResponseService; this.springDocConfigProperties = springDocConfigProperties; } @Override public List getRouterOperations(OpenAPI openAPI) { + GenericResponseService genericResponseService = applicationContext.getBean(GenericResponseService.class); List routerOperationList = new ArrayList<>(); functionCatalogOptional.ifPresent( functionCatalog -> { @@ -117,7 +111,7 @@ public List getRouterOperations(OpenAPI openAPI) { for (RequestMethod requestMethod : functionRequestMethods) { RouterOperation routerOperation = buildRouterOperation(name, " function", requestMethod, routerOperationList); buildRequest(openAPI, name, function, requestMethod, routerOperation); - ApiResponses apiResponses = buildResponses(openAPI, function, defaultMediaTypes); + ApiResponses apiResponses = buildResponses(openAPI, function, defaultMediaTypes, genericResponseService); routerOperation.getOperationModel().responses(apiResponses); if (StringUtils.isEmpty(prefix)) { if (GET.equals(requestMethod)) @@ -145,28 +139,14 @@ else if (function.isConsumer()) { ApiResponse apiResponse = new ApiResponse(); apiResponse.setContent(new Content()); apiResponses.put(String.valueOf(HttpStatus.ACCEPTED.value()), apiResponse.description(HttpStatus.ACCEPTED.getReasonPhrase())); - routerOperation.getOperationModel().responses(apiResponses); - if (StringUtils.isEmpty(prefix)) - routerOperation.setPath(AntPathMatcher.DEFAULT_PATH_SEPARATOR + name); - else - routerOperation.setPath(prefix + AntPathMatcher.DEFAULT_PATH_SEPARATOR + name); - RouterOperation userRouterOperation = this.getRouterFunctionPaths(name, requestMethod); - if (userRouterOperation != null) - mergeRouterOperation(routerOperation, userRouterOperation); + getRouterOperationsCommon(name, requestMethod, routerOperation, apiResponses); } } else if (function.isSupplier()) { for (RequestMethod requestMethod : supplierRequestMethods) { RouterOperation routerOperation = buildRouterOperation(name, " supplier", requestMethod, routerOperationList); - ApiResponses apiResponses = buildResponses(openAPI, function, new String[] { springDocConfigProperties.getDefaultProducesMediaType() }); - routerOperation.getOperationModel().responses(apiResponses); - if (StringUtils.isEmpty(prefix)) - routerOperation.setPath(AntPathMatcher.DEFAULT_PATH_SEPARATOR + name); - else - routerOperation.setPath(prefix + AntPathMatcher.DEFAULT_PATH_SEPARATOR + name); - RouterOperation userRouterOperation = this.getRouterFunctionPaths(name, requestMethod); - if (userRouterOperation != null) - mergeRouterOperation(routerOperation, userRouterOperation); + ApiResponses apiResponses = buildResponses(openAPI, function, new String[] { springDocConfigProperties.getDefaultProducesMediaType() }, genericResponseService); + getRouterOperationsCommon(name, requestMethod, routerOperation, apiResponses); } } } @@ -176,6 +156,25 @@ else if (function.isSupplier()) { return routerOperationList; } + /** + * Gets router operation common. + * + * @param name the name + * @param requestMethod the request method + * @param routerOperation the router operation + * @param apiResponses the api responses + */ + private void getRouterOperationsCommon(String name, RequestMethod requestMethod, RouterOperation routerOperation, ApiResponses apiResponses) { + routerOperation.getOperationModel().responses(apiResponses); + if (StringUtils.isEmpty(prefix)) + routerOperation.setPath(AntPathMatcher.DEFAULT_PATH_SEPARATOR + name); + else + routerOperation.setPath(prefix + AntPathMatcher.DEFAULT_PATH_SEPARATOR + name); + RouterOperation userRouterOperation = this.getRouterFunctionPaths(name, requestMethod); + if (userRouterOperation != null) + mergeRouterOperation(routerOperation, userRouterOperation); + } + /** * Build request. * @@ -230,9 +229,10 @@ private RouterOperation buildRouterOperation(String name, String type, RequestMe * @param openAPI the open api * @param function the function * @param mediaTypes the media types + * @param genericResponseService the generic response service * @return the api responses */ - private ApiResponses buildResponses(OpenAPI openAPI, FunctionInvocationWrapper function, String[] mediaTypes) { + private ApiResponses buildResponses(OpenAPI openAPI, FunctionInvocationWrapper function, String[] mediaTypes, GenericResponseService genericResponseService) { Type returnType = function.getOutputType(); Content content = genericResponseService.buildContent(openAPI.getComponents(), null, mediaTypes, null, returnType); ApiResponses apiResponses = new ApiResponses(); @@ -247,6 +247,7 @@ private ApiResponses buildResponses(OpenAPI openAPI, FunctionInvocationWrapper f * Gets router function paths. * * @param beanName the bean name + * @param requestMethod the request method * @return the router function paths */ protected RouterOperation getRouterFunctionPaths(String beanName, RequestMethod requestMethod) { diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/ui/AbstractSwaggerIndexTransformer.java b/springdoc-openapi-common/src/main/java/org/springdoc/ui/AbstractSwaggerIndexTransformer.java index 4709f6e0e..626dde71c 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/ui/AbstractSwaggerIndexTransformer.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/ui/AbstractSwaggerIndexTransformer.java @@ -30,12 +30,12 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import io.swagger.v3.core.util.Json; import org.apache.commons.lang3.StringUtils; import org.springdoc.core.Constants; import org.springdoc.core.SwaggerUiConfigParameters; import org.springdoc.core.SwaggerUiConfigProperties; import org.springdoc.core.SwaggerUiOAuthProperties; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springframework.util.CollectionUtils; @@ -79,11 +79,11 @@ public class AbstractSwaggerIndexTransformer { * @param swaggerUiOAuthProperties the swagger ui o auth properties * @param swaggerUiConfigParameters the swagger ui config parameters */ - public AbstractSwaggerIndexTransformer(SwaggerUiConfigProperties swaggerUiConfig, SwaggerUiOAuthProperties swaggerUiOAuthProperties, SwaggerUiConfigParameters swaggerUiConfigParameters) { + public AbstractSwaggerIndexTransformer(SwaggerUiConfigProperties swaggerUiConfig, SwaggerUiOAuthProperties swaggerUiOAuthProperties, SwaggerUiConfigParameters swaggerUiConfigParameters, ObjectMapperProvider objectMapperProvider) { this.swaggerUiConfig = swaggerUiConfig; this.swaggerUiOAuthProperties = swaggerUiOAuthProperties; this.swaggerUiConfigParameters = swaggerUiConfigParameters; - this.objectMapper = Json.mapper(); + this.objectMapper = objectMapperProvider.jsonMapper(); } /** diff --git a/springdoc-openapi-common/src/test/java/org/springdoc/api/AbstractOpenApiResourceTest.java b/springdoc-openapi-common/src/test/java/org/springdoc/api/AbstractOpenApiResourceTest.java index 2544ebc10..eaaccd0f7 100644 --- a/springdoc-openapi-common/src/test/java/org/springdoc/api/AbstractOpenApiResourceTest.java +++ b/springdoc-openapi-common/src/test/java/org/springdoc/api/AbstractOpenApiResourceTest.java @@ -27,6 +27,7 @@ import java.util.Map; import java.util.Optional; +import io.swagger.v3.core.util.Json; import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; @@ -119,6 +120,7 @@ public void setUp() { when(openAPIService.getContext()).thenReturn(context); when(openAPIBuilderObjectFactory.getObject()).thenReturn(openAPIService); + when(springDocProviders.jsonMapper()).thenReturn(Json.mapper()); } @Test diff --git a/springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/DataRestHalProvider.java b/springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/DataRestHalProvider.java index 10dd544a3..e361bb6f9 100644 --- a/springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/DataRestHalProvider.java +++ b/springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/DataRestHalProvider.java @@ -27,7 +27,7 @@ import javax.annotation.PostConstruct; -import io.swagger.v3.core.util.Json; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springdoc.hateoas.HateoasHalProvider; import org.springframework.boot.autoconfigure.hateoas.HateoasProperties; @@ -45,15 +45,23 @@ public class DataRestHalProvider extends HateoasHalProvider { */ private Optional repositoryRestConfigurationOptional; + /** + * The Object mapper provider. + */ + private final ObjectMapperProvider objectMapperProvider; + /** * Instantiates a new Data rest hal provider. * - * @param repositoryRestConfigurationOptional the repository rest configuration optional + * @param repositoryRestConfigurationOptional the repository rest configuration optional * @param hateoasPropertiesOptional the hateoas properties optional + * @param objectMapperProvider the object mapper provider */ - public DataRestHalProvider(Optional repositoryRestConfigurationOptional,Optional hateoasPropertiesOptional) { - super(hateoasPropertiesOptional); + public DataRestHalProvider(Optional repositoryRestConfigurationOptional,Optional hateoasPropertiesOptional, + ObjectMapperProvider objectMapperProvider) { + super(hateoasPropertiesOptional, objectMapperProvider); this.repositoryRestConfigurationOptional = repositoryRestConfigurationOptional; + this.objectMapperProvider = objectMapperProvider; } @PostConstruct @@ -61,8 +69,8 @@ public DataRestHalProvider(Optional repositoryRestC protected void init() { if (!isHalEnabled()) return; - if (!Jackson2HalModule.isAlreadyRegisteredIn(Json.mapper())) - Json.mapper().registerModule(new Jackson2HalModule()); + if (!Jackson2HalModule.isAlreadyRegisteredIn(objectMapperProvider.jsonMapper())) + objectMapperProvider.jsonMapper().registerModule(new Jackson2HalModule()); } @Override diff --git a/springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/SpringDocDataRestConfiguration.java b/springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/SpringDocDataRestConfiguration.java index d5594c22c..247c0f221 100644 --- a/springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/SpringDocDataRestConfiguration.java +++ b/springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/SpringDocDataRestConfiguration.java @@ -35,6 +35,7 @@ import org.springdoc.core.RequestBodyService; import org.springdoc.core.SpringDocConfigProperties; import org.springdoc.core.converters.models.DefaultPageable; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springdoc.data.rest.core.DataRestOperationService; import org.springdoc.data.rest.core.DataRestRequestService; import org.springdoc.data.rest.core.DataRestResponseService; @@ -90,8 +91,8 @@ public class SpringDocDataRestConfiguration { @ConditionalOnMissingBean @Primary @Lazy(false) - DataRestHalProvider halProvider(Optional repositoryRestConfiguration, Optional hateoasPropertiesOptional) { - return new DataRestHalProvider(repositoryRestConfiguration, hateoasPropertiesOptional); + DataRestHalProvider halProvider(Optional repositoryRestConfiguration, Optional hateoasPropertiesOptional, ObjectMapperProvider objectMapperProvider) { + return new DataRestHalProvider(repositoryRestConfiguration, hateoasPropertiesOptional, objectMapperProvider); } diff --git a/springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java b/springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java index fdd13e752..6d5c09dba 100644 --- a/springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java +++ b/springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java @@ -26,12 +26,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; import com.fasterxml.jackson.databind.type.ClassKey; -import io.swagger.v3.core.util.Json; 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; @@ -44,10 +45,13 @@ static class SpringDocTestApp {} private Map> springMixins = new HashMap<>(); + @Autowired + ObjectMapperProvider objectMapperProvider; + @BeforeEach void init() throws IllegalAccessException { Field convertersField2 = FieldUtils.getDeclaredField(ObjectMapper.class, "_mixIns", true); - SimpleMixInResolver _mixIns = (SimpleMixInResolver) convertersField2.get(Json.mapper()); + SimpleMixInResolver _mixIns = (SimpleMixInResolver) convertersField2.get(objectMapperProvider.jsonMapper()); Field convertersField3 = FieldUtils.getDeclaredField(SimpleMixInResolver.class, "_localMixIns", true); Map> _localMixIns = (Map>) convertersField3.get(_mixIns); Iterator>> it = _localMixIns.entrySet().iterator(); @@ -64,7 +68,7 @@ void init() throws IllegalAccessException { @AfterEach private void clean() throws IllegalAccessException { Field convertersField2 = FieldUtils.getDeclaredField(ObjectMapper.class, "_mixIns", true); - SimpleMixInResolver _mixIns = (SimpleMixInResolver) convertersField2.get(Json.mapper()); + SimpleMixInResolver _mixIns = (SimpleMixInResolver) convertersField2.get(objectMapperProvider.jsonMapper()); Field convertersField3 = FieldUtils.getDeclaredField(SimpleMixInResolver.class, "_localMixIns", true); Map> _localMixIns = (Map>) convertersField3.get(_mixIns); _localMixIns.putAll(springMixins); diff --git a/springdoc-openapi-groovy/src/main/java/org/springdoc/groovy/SpringDocGroovyConfiguration.java b/springdoc-openapi-groovy/src/main/java/org/springdoc/groovy/SpringDocGroovyConfiguration.java index bda53c578..d04793287 100644 --- a/springdoc-openapi-groovy/src/main/java/org/springdoc/groovy/SpringDocGroovyConfiguration.java +++ b/springdoc-openapi-groovy/src/main/java/org/springdoc/groovy/SpringDocGroovyConfiguration.java @@ -21,6 +21,7 @@ import groovy.lang.MetaClass; import org.springdoc.core.SpringDocUtils; import org.springdoc.core.converters.RequestTypeToIgnoreConverter; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; @@ -57,7 +58,7 @@ Object ignoreGroovyMetaClass() { */ @Bean @Lazy(false) - RequestTypeToIgnoreConverter requestTypeToIgnoreConverter() { - return new RequestTypeToIgnoreConverter(); + RequestTypeToIgnoreConverter requestTypeToIgnoreConverter(ObjectMapperProvider springDocObjectMapper) { + return new RequestTypeToIgnoreConverter(springDocObjectMapper); } } diff --git a/springdoc-openapi-hateoas/src/main/java/org/springdoc/hateoas/HateoasHalProvider.java b/springdoc-openapi-hateoas/src/main/java/org/springdoc/hateoas/HateoasHalProvider.java index 1823f69f0..bb0432c83 100644 --- a/springdoc-openapi-hateoas/src/main/java/org/springdoc/hateoas/HateoasHalProvider.java +++ b/springdoc-openapi-hateoas/src/main/java/org/springdoc/hateoas/HateoasHalProvider.java @@ -24,7 +24,7 @@ import javax.annotation.PostConstruct; -import io.swagger.v3.core.util.Json; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springframework.boot.autoconfigure.hateoas.HateoasProperties; import org.springframework.hateoas.mediatype.hal.Jackson2HalModule; @@ -40,13 +40,16 @@ public class HateoasHalProvider { */ private final Optional hateoasPropertiesOptional; + private final ObjectMapperProvider objectMapperProvider; + /** * Instantiates a new Hateoas hal provider. * * @param hateoasPropertiesOptional the hateoas properties optional */ - public HateoasHalProvider(Optional hateoasPropertiesOptional) { + public HateoasHalProvider(Optional hateoasPropertiesOptional, ObjectMapperProvider objectMapperProvider) { this.hateoasPropertiesOptional = hateoasPropertiesOptional; + this.objectMapperProvider = objectMapperProvider; } /** @@ -56,8 +59,8 @@ public HateoasHalProvider(Optional hateoasPropertiesOptional) protected void init() { if (!isHalEnabled()) return; - if (!Jackson2HalModule.isAlreadyRegisteredIn(Json.mapper())) - Json.mapper().registerModule(new Jackson2HalModule()); + if (!Jackson2HalModule.isAlreadyRegisteredIn(objectMapperProvider.jsonMapper())) + objectMapperProvider.jsonMapper().registerModule(new Jackson2HalModule()); } /** diff --git a/springdoc-openapi-hateoas/src/main/java/org/springdoc/hateoas/SpringDocHateoasConfiguration.java b/springdoc-openapi-hateoas/src/main/java/org/springdoc/hateoas/SpringDocHateoasConfiguration.java index d198e89e1..4b309cb5c 100644 --- a/springdoc-openapi-hateoas/src/main/java/org/springdoc/hateoas/SpringDocHateoasConfiguration.java +++ b/springdoc-openapi-hateoas/src/main/java/org/springdoc/hateoas/SpringDocHateoasConfiguration.java @@ -27,6 +27,7 @@ import io.swagger.v3.core.util.Json; import org.springdoc.core.SpringDocConfigProperties; import org.springdoc.core.customizers.OpenApiCustomiser; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springdoc.hateoas.converters.CollectionModelContentConverter; import org.springdoc.hateoas.converters.OpenApiHateoasLinksCustomiser; import org.springdoc.hateoas.converters.RepresentationModelLinksOASMixin; @@ -59,13 +60,14 @@ public class SpringDocHateoasConfiguration { * Hateoas hal provider hateoas hal provider. * * @param hateoasPropertiesOptional the hateoas properties optional + * @param objectMapperProvider the object mapper provider * @return the hateoas hal provider */ @Bean @ConditionalOnMissingBean @Lazy(false) - HateoasHalProvider hateoasHalProvider(Optional hateoasPropertiesOptional) { - return new HateoasHalProvider(hateoasPropertiesOptional); + HateoasHalProvider hateoasHalProvider(Optional hateoasPropertiesOptional, ObjectMapperProvider objectMapperProvider) { + return new HateoasHalProvider(hateoasPropertiesOptional, objectMapperProvider); } /** @@ -88,18 +90,19 @@ 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 customiser - * @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) + * @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) */ @Bean(LINKS_SCHEMA_CUSTOMISER) @ConditionalOnMissingBean @Lazy(false) - OpenApiCustomiser linksSchemaCustomiser(HateoasHalProvider halProvider, SpringDocConfigProperties springDocConfigProperties) { + OpenApiCustomiser linksSchemaCustomiser(HateoasHalProvider halProvider, SpringDocConfigProperties springDocConfigProperties, ObjectMapperProvider objectMapperProvider) { if (!halProvider.isHalEnabled()) { return openApi -> { }; } - Json.mapper().addMixIn(RepresentationModel.class, RepresentationModelLinksOASMixin.class); + objectMapperProvider.jsonMapper().addMixIn(RepresentationModel.class, RepresentationModelLinksOASMixin.class); return new OpenApiHateoasLinksCustomiser(springDocConfigProperties); } diff --git a/springdoc-openapi-hateoas/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java b/springdoc-openapi-hateoas/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java index 64ff43d83..57461bee3 100644 --- a/springdoc-openapi-hateoas/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java +++ b/springdoc-openapi-hateoas/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java @@ -27,12 +27,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; import com.fasterxml.jackson.databind.type.ClassKey; -import io.swagger.v3.core.util.Json; 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; @@ -43,12 +44,15 @@ public class SpringDocApp6Test extends AbstractSpringDocTest { static class SpringDocTestApp { } + @Autowired + ObjectMapperProvider objectMapperProvider; + private Map> springMixins = new HashMap<>(); @BeforeEach void init() throws IllegalAccessException { Field convertersField2 = FieldUtils.getDeclaredField(ObjectMapper.class, "_mixIns", true); - SimpleMixInResolver _mixIns = (SimpleMixInResolver) convertersField2.get(Json.mapper()); + SimpleMixInResolver _mixIns = (SimpleMixInResolver) convertersField2.get(objectMapperProvider.jsonMapper()); Field convertersField3 = FieldUtils.getDeclaredField(SimpleMixInResolver.class, "_localMixIns", true); Map> _localMixIns = (Map>) convertersField3.get(_mixIns); Iterator>> it = _localMixIns.entrySet().iterator(); @@ -65,7 +69,7 @@ void init() throws IllegalAccessException { @AfterEach private void clean() throws IllegalAccessException { Field convertersField2 = FieldUtils.getDeclaredField(ObjectMapper.class, "_mixIns", true); - SimpleMixInResolver _mixIns = (SimpleMixInResolver) convertersField2.get(Json.mapper()); + SimpleMixInResolver _mixIns = (SimpleMixInResolver) convertersField2.get(objectMapperProvider.jsonMapper()); Field convertersField3 = FieldUtils.getDeclaredField(SimpleMixInResolver.class, "_localMixIns", true); Map> _localMixIns = (Map>) convertersField3.get(_mixIns); _localMixIns.putAll(springMixins); diff --git a/springdoc-openapi-javadoc/src/main/java/org/springdoc/openapi/javadoc/JavadocPropertyCustomizer.java b/springdoc-openapi-javadoc/src/main/java/org/springdoc/openapi/javadoc/JavadocPropertyCustomizer.java index 0638934ca..b16e4c79e 100644 --- a/springdoc-openapi-javadoc/src/main/java/org/springdoc/openapi/javadoc/JavadocPropertyCustomizer.java +++ b/springdoc-openapi-javadoc/src/main/java/org/springdoc/openapi/javadoc/JavadocPropertyCustomizer.java @@ -29,11 +29,11 @@ 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.core.util.Json; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.reflect.FieldUtils; import org.springdoc.core.providers.JavadocProvider; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springframework.util.CollectionUtils; @@ -48,13 +48,20 @@ public class JavadocPropertyCustomizer implements ModelConverter { */ private final JavadocProvider javadocProvider; + /** + * The Object mapper provider. + */ + private final ObjectMapperProvider objectMapperProvider; + /** * Instantiates a new Javadoc property customizer. * * @param javadocProvider the javadoc provider + * @param objectMapperProvider the object mapper provider */ - public JavadocPropertyCustomizer(JavadocProvider javadocProvider) { + public JavadocPropertyCustomizer(JavadocProvider javadocProvider, ObjectMapperProvider objectMapperProvider) { this.javadocProvider = javadocProvider; + this.objectMapperProvider = objectMapperProvider; } /** @@ -68,7 +75,7 @@ public JavadocPropertyCustomizer(JavadocProvider javadocProvider) { @Override public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator chain) { if (chain.hasNext()) { - JavaType javaType = Json.mapper().constructType(type.getType()); + JavaType javaType = objectMapperProvider.jsonMapper().constructType(type.getType()); if (javaType != null) { Class cls = javaType.getRawClass(); Schema resolvedSchema = chain.next().resolve(type, context, chain); @@ -93,6 +100,7 @@ else if (resolvedSchema != null && resolvedSchema.get$ref() != null && resolvedS /** * Sets javadoc description. * + * @param cls the cls * @param fields the fields * @param existingSchema the existing schema */ diff --git a/springdoc-openapi-javadoc/src/main/java/org/springdoc/openapi/javadoc/SpringDocJavadocConfiguration.java b/springdoc-openapi-javadoc/src/main/java/org/springdoc/openapi/javadoc/SpringDocJavadocConfiguration.java index 0cfaca6e4..fbec05e65 100644 --- a/springdoc-openapi-javadoc/src/main/java/org/springdoc/openapi/javadoc/SpringDocJavadocConfiguration.java +++ b/springdoc-openapi-javadoc/src/main/java/org/springdoc/openapi/javadoc/SpringDocJavadocConfiguration.java @@ -21,9 +21,11 @@ package org.springdoc.openapi.javadoc; import org.springdoc.core.providers.JavadocProvider; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; @@ -37,6 +39,7 @@ @Lazy(false) @Configuration(proxyBeanMethods = false) @ConditionalOnProperty(name = SPRINGDOC_ENABLED, matchIfMissing = true) +@ConditionalOnWebApplication public class SpringDocJavadocConfiguration { /** @@ -55,12 +58,13 @@ SpringDocJavadocProvider springDocJavadocProvider( ) { * Javadoc property customizer javadoc property customizer. * * @param javadocProvider the javadoc provider + * @param objectMapperProvider the object mapper provider * @return the javadoc property customizer */ @Bean @ConditionalOnMissingBean @Lazy(false) - JavadocPropertyCustomizer javadocPropertyCustomizer( JavadocProvider javadocProvider){ - return new JavadocPropertyCustomizer(javadocProvider); + JavadocPropertyCustomizer javadocPropertyCustomizer( JavadocProvider javadocProvider, ObjectMapperProvider objectMapperProvider){ + return new JavadocPropertyCustomizer(javadocProvider, objectMapperProvider); } } diff --git a/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app157/SpringDocApp157Test.java b/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app157/SpringDocApp157Test.java index 911526298..fbc2eb5cc 100644 --- a/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app157/SpringDocApp157Test.java +++ b/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app157/SpringDocApp157Test.java @@ -4,11 +4,11 @@ import io.swagger.v3.core.converter.ModelConverters; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springdoc.core.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; @@ -31,30 +31,20 @@ public class SpringDocApp157Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringBootApp {} - /** - * The My converter. - */ - private StringyConverter myConverter = new StringyConverter(); + @Autowired + StringyConverter converter; /** * The Converters. */ private ModelConverters converters = ModelConverters.getInstance(); - /** - * Register converter. - */ - @BeforeEach - public void registerConverter() { - converters.addConverter(myConverter); - } - /** * Unregister converter. */ @AfterEach public void unregisterConverter() { - converters.removeConverter(myConverter); + converters.removeConverter(converter); } /** diff --git a/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app157/StringyConverter.java b/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app157/StringyConverter.java index 85d94fe84..b558db140 100644 --- a/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app157/StringyConverter.java +++ b/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app157/StringyConverter.java @@ -6,14 +6,25 @@ import io.swagger.v3.core.converter.AnnotatedType; import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.converter.ModelConverterContext; -import io.swagger.v3.core.util.Json; 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; /** * The type Stringy converter. */ +@Component public class StringyConverter implements ModelConverter { + @Autowired + ObjectMapperProvider objectMapperProvider; + + public StringyConverter(ObjectMapperProvider objectMapperProvider) { + this.objectMapperProvider = objectMapperProvider; + } + /** * Resolve schema. * @@ -26,7 +37,7 @@ public class StringyConverter implements ModelConverter { public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator chain) { - JavaType javaType = Json.mapper().constructType(type.getType()); + JavaType javaType = objectMapperProvider.jsonMapper().constructType(type.getType()); if (javaType.getRawClass().equals(String.class)) { type.getParent().addRequiredItem("stringy"); diff --git a/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app70/customizer/PropertyCustomizer.java b/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app70/customizer/PropertyCustomizer.java index b0eafc12e..2ffc34efc 100644 --- a/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app70/customizer/PropertyCustomizer.java +++ b/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app70/customizer/PropertyCustomizer.java @@ -26,10 +26,11 @@ import com.fasterxml.jackson.databind.JavaType; import io.swagger.v3.core.converter.AnnotatedType; -import io.swagger.v3.core.util.Json; 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; /** @@ -37,6 +38,10 @@ */ @Component public class PropertyCustomizer implements org.springdoc.core.customizers.PropertyCustomizer { + + @Autowired + ObjectMapperProvider objectMapperProvider; + /** * Customize schema. * @@ -56,7 +61,7 @@ public Schema customize(Schema property, AnnotatedType type) { .findFirst() .map(CustomizedProperty.class::cast); - JavaType javaType = Json.mapper().constructType(type.getType()); + JavaType javaType = objectMapperProvider.jsonMapper().constructType(type.getType()); if (javaType.getRawClass().equals(Duration.class)) { property = new StringSchema().format("duration").properties(Collections.emptyMap()); } diff --git a/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java b/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java index c48594f33..a4365fbd8 100644 --- a/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java +++ b/springdoc-openapi-javadoc/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java @@ -65,7 +65,7 @@ public void actuator_configuration_not_loaded_when_not_enabled_explicitly() { .run(context -> assertThat(context) .hasNotFailed() .hasBean("openApiResource") - .doesNotHaveBean("actuatorPprrovider") + .doesNotHaveBean("actuatorProvider") .hasBean("multipleOpenApiResource") ); } diff --git a/springdoc-openapi-kotlin/src/main/java/org/springdoc/kotlin/SpringDocKotlinConfiguration.java b/springdoc-openapi-kotlin/src/main/java/org/springdoc/kotlin/SpringDocKotlinConfiguration.java index 2c39d9963..8ed81bd70 100644 --- a/springdoc-openapi-kotlin/src/main/java/org/springdoc/kotlin/SpringDocKotlinConfiguration.java +++ b/springdoc-openapi-kotlin/src/main/java/org/springdoc/kotlin/SpringDocKotlinConfiguration.java @@ -21,9 +21,9 @@ package org.springdoc.kotlin; import com.fasterxml.jackson.module.kotlin.KotlinModule; -import io.swagger.v3.core.util.Json; import kotlin.Deprecated; import kotlin.coroutines.Continuation; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -43,10 +43,21 @@ @ConditionalOnProperty(name = SPRINGDOC_ENABLED, matchIfMissing = true) public class SpringDocKotlinConfiguration { - static { + /** + * The Object mapper provider. + */ + private final ObjectMapperProvider objectMapperProvider; + + /** + * Instantiates a new Spring doc kotlin configuration. + * + * @param objectMapperProvider the object mapper provider + */ + public SpringDocKotlinConfiguration(ObjectMapperProvider objectMapperProvider) { + this.objectMapperProvider = objectMapperProvider; getConfig().addRequestWrapperToIgnore(Continuation.class) .addDeprecatedType(Deprecated.class); - Json.mapper().registerModule(new KotlinModule()); + objectMapperProvider.jsonMapper().registerModule(new KotlinModule()); } /** diff --git a/springdoc-openapi-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerConfig.java b/springdoc-openapi-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerConfig.java index 837d0bcf1..9e0482b8b 100644 --- a/springdoc-openapi-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerConfig.java +++ b/springdoc-openapi-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerConfig.java @@ -28,6 +28,7 @@ import org.springdoc.core.SwaggerUiConfigProperties; import org.springdoc.core.SwaggerUiOAuthProperties; import org.springdoc.core.providers.ActuatorProvider; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springdoc.core.providers.SpringWebProvider; import org.springdoc.webmvc.core.SpringWebMvcProvider; @@ -124,13 +125,15 @@ SwaggerUiHome swaggerUiHome() { * @param swaggerUiOAuthProperties the swagger ui o auth properties * @param swaggerUiConfigParameters the swagger ui config parameters * @param swaggerWelcomeCommon the swagger welcome common + * @param objectMapperProvider the object mapper provider * @return the swagger index transformer */ @Bean @ConditionalOnMissingBean @Lazy(false) - SwaggerIndexTransformer indexPageTransformer(SwaggerUiConfigProperties swaggerUiConfig, SwaggerUiOAuthProperties swaggerUiOAuthProperties, SwaggerUiConfigParameters swaggerUiConfigParameters, SwaggerWelcomeCommon swaggerWelcomeCommon) { - return new SwaggerIndexPageTransformer(swaggerUiConfig, swaggerUiOAuthProperties, swaggerUiConfigParameters, swaggerWelcomeCommon); + SwaggerIndexTransformer indexPageTransformer(SwaggerUiConfigProperties swaggerUiConfig, SwaggerUiOAuthProperties swaggerUiOAuthProperties, + SwaggerUiConfigParameters swaggerUiConfigParameters, SwaggerWelcomeCommon swaggerWelcomeCommon, ObjectMapperProvider objectMapperProvider) { + return new SwaggerIndexPageTransformer(swaggerUiConfig, swaggerUiOAuthProperties, swaggerUiConfigParameters, swaggerWelcomeCommon, objectMapperProvider); } /** diff --git a/springdoc-openapi-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerIndexPageTransformer.java b/springdoc-openapi-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerIndexPageTransformer.java index c342258e8..f5172060c 100644 --- a/springdoc-openapi-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerIndexPageTransformer.java +++ b/springdoc-openapi-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerIndexPageTransformer.java @@ -27,6 +27,7 @@ import org.springdoc.core.SwaggerUiConfigParameters; import org.springdoc.core.SwaggerUiConfigProperties; import org.springdoc.core.SwaggerUiOAuthProperties; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springdoc.ui.AbstractSwaggerIndexTransformer; import org.springframework.core.io.Resource; @@ -54,8 +55,9 @@ public class SwaggerIndexPageTransformer extends AbstractSwaggerIndexTransformer * @param swaggerUiConfigParameters the swagger ui config parameters * @param swaggerWelcomeCommon the swagger welcome common */ - public SwaggerIndexPageTransformer(SwaggerUiConfigProperties swaggerUiConfig, SwaggerUiOAuthProperties swaggerUiOAuthProperties, SwaggerUiConfigParameters swaggerUiConfigParameters, SwaggerWelcomeCommon swaggerWelcomeCommon) { - super(swaggerUiConfig, swaggerUiOAuthProperties, swaggerUiConfigParameters); + public SwaggerIndexPageTransformer(SwaggerUiConfigProperties swaggerUiConfig, SwaggerUiOAuthProperties swaggerUiOAuthProperties, + SwaggerUiConfigParameters swaggerUiConfigParameters, SwaggerWelcomeCommon swaggerWelcomeCommon, ObjectMapperProvider objectMapperProvider) { + super(swaggerUiConfig, swaggerUiOAuthProperties, swaggerUiConfigParameters, objectMapperProvider); this.swaggerWelcomeCommon = swaggerWelcomeCommon; } diff --git a/springdoc-openapi-ui/src/test/java/test/org/springdoc/ui/app22/SpringDocTestApp.java b/springdoc-openapi-ui/src/test/java/test/org/springdoc/ui/app22/SpringDocTestApp.java index 6465a6d9f..3f63ed818 100644 --- a/springdoc-openapi-ui/src/test/java/test/org/springdoc/ui/app22/SpringDocTestApp.java +++ b/springdoc-openapi-ui/src/test/java/test/org/springdoc/ui/app22/SpringDocTestApp.java @@ -20,6 +20,7 @@ import org.springdoc.core.SpringDocConfigProperties; import org.springdoc.core.SpringDocConfiguration; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -38,8 +39,12 @@ SpringDocConfiguration springDocConfiguration(){ } @Bean - public SpringDocConfigProperties springDocConfigProperties() { + SpringDocConfigProperties springDocConfigProperties() { return new SpringDocConfigProperties(); } + @Bean + ObjectMapperProvider objectMapperProvider(SpringDocConfigProperties springDocConfigProperties){ + return new ObjectMapperProvider(springDocConfigProperties); + } } \ No newline at end of file diff --git a/springdoc-openapi-webflux-core/src/main/java/org/springdoc/webflux/core/SpringDocWebFluxConfiguration.java b/springdoc-openapi-webflux-core/src/main/java/org/springdoc/webflux/core/SpringDocWebFluxConfiguration.java index 99da1c08c..a17b3e382 100644 --- a/springdoc-openapi-webflux-core/src/main/java/org/springdoc/webflux/core/SpringDocWebFluxConfiguration.java +++ b/springdoc-openapi-webflux-core/src/main/java/org/springdoc/webflux/core/SpringDocWebFluxConfiguration.java @@ -38,6 +38,7 @@ import org.springdoc.core.customizers.ParameterCustomizer; import org.springdoc.core.filters.OpenApiMethodFilter; import org.springdoc.core.providers.ActuatorProvider; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springdoc.core.providers.SpringWebProvider; import org.springdoc.webflux.api.OpenApiActuatorResource; import org.springdoc.webflux.api.OpenApiWebfluxResource; @@ -144,13 +145,14 @@ GenericResponseService responseBuilder(OperationService operationService, List chain) { - JavaType javaType = Json.mapper().constructType(type.getType()); + JavaType javaType = objectMapperProvider.jsonMapper().constructType(type.getType()); if (javaType != null) { Class cls = javaType.getRawClass(); if (isFluxTypeWrapper(cls)) { diff --git a/springdoc-openapi-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerConfig.java b/springdoc-openapi-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerConfig.java index 8edfe2b1c..8911ce2b3 100644 --- a/springdoc-openapi-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerConfig.java +++ b/springdoc-openapi-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerConfig.java @@ -28,6 +28,7 @@ import org.springdoc.core.SwaggerUiConfigProperties; import org.springdoc.core.SwaggerUiOAuthProperties; import org.springdoc.core.providers.ActuatorProvider; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springdoc.core.providers.SpringWebProvider; import org.springdoc.webflux.core.SpringWebFluxProvider; @@ -132,13 +133,15 @@ SwaggerWebFluxConfigurer swaggerWebFluxConfigurer(SwaggerUiConfigParameters swag * @param swaggerUiOAuthProperties the swagger ui o auth properties * @param swaggerUiConfigParameters the swagger ui config parameters * @param swaggerWelcomeCommon the swagger welcome common + * @param objectMapperProvider the object mapper provider * @return the swagger index transformer */ @Bean @ConditionalOnMissingBean @Lazy(false) - SwaggerIndexTransformer indexPageTransformer(SwaggerUiConfigProperties swaggerUiConfig ,SwaggerUiOAuthProperties swaggerUiOAuthProperties, SwaggerUiConfigParameters swaggerUiConfigParameters,SwaggerWelcomeCommon swaggerWelcomeCommon) { - return new SwaggerIndexPageTransformer(swaggerUiConfig, swaggerUiOAuthProperties,swaggerUiConfigParameters, swaggerWelcomeCommon); + SwaggerIndexTransformer indexPageTransformer(SwaggerUiConfigProperties swaggerUiConfig ,SwaggerUiOAuthProperties swaggerUiOAuthProperties, + SwaggerUiConfigParameters swaggerUiConfigParameters,SwaggerWelcomeCommon swaggerWelcomeCommon, ObjectMapperProvider objectMapperProvider) { + return new SwaggerIndexPageTransformer(swaggerUiConfig, swaggerUiOAuthProperties,swaggerUiConfigParameters, swaggerWelcomeCommon, objectMapperProvider); } /** diff --git a/springdoc-openapi-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerIndexPageTransformer.java b/springdoc-openapi-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerIndexPageTransformer.java index 7ce7f1412..0550c1442 100644 --- a/springdoc-openapi-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerIndexPageTransformer.java +++ b/springdoc-openapi-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerIndexPageTransformer.java @@ -23,6 +23,7 @@ import org.springdoc.core.SwaggerUiConfigParameters; import org.springdoc.core.SwaggerUiConfigProperties; import org.springdoc.core.SwaggerUiOAuthProperties; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springdoc.ui.AbstractSwaggerIndexTransformer; import org.springdoc.ui.SpringDocUIException; import reactor.core.publisher.Mono; @@ -52,9 +53,11 @@ public class SwaggerIndexPageTransformer extends AbstractSwaggerIndexTransformer * @param swaggerUiOAuthProperties the swagger ui o auth properties * @param swaggerUiConfigParameters the swagger ui config parameters * @param swaggerWelcomeCommon the swagger welcome common + * @param objectMapperProvider the object mapper providern */ - public SwaggerIndexPageTransformer(SwaggerUiConfigProperties swaggerUiConfig, SwaggerUiOAuthProperties swaggerUiOAuthProperties, SwaggerUiConfigParameters swaggerUiConfigParameters, SwaggerWelcomeCommon swaggerWelcomeCommon) { - super(swaggerUiConfig, swaggerUiOAuthProperties, swaggerUiConfigParameters); + public SwaggerIndexPageTransformer(SwaggerUiConfigProperties swaggerUiConfig, SwaggerUiOAuthProperties swaggerUiOAuthProperties, + SwaggerUiConfigParameters swaggerUiConfigParameters, SwaggerWelcomeCommon swaggerWelcomeCommon, ObjectMapperProvider objectMapperProvider) { + super(swaggerUiConfig, swaggerUiOAuthProperties, swaggerUiConfigParameters, objectMapperProvider); this.swaggerWelcomeCommon = swaggerWelcomeCommon; } diff --git a/springdoc-openapi-webflux-ui/src/test/java/test/org/springdoc/ui/app24/SpringDocConfig.java b/springdoc-openapi-webflux-ui/src/test/java/test/org/springdoc/ui/app24/SpringDocConfig.java index 01f98c5cd..c6cbc4157 100644 --- a/springdoc-openapi-webflux-ui/src/test/java/test/org/springdoc/ui/app24/SpringDocConfig.java +++ b/springdoc-openapi-webflux-ui/src/test/java/test/org/springdoc/ui/app24/SpringDocConfig.java @@ -2,6 +2,7 @@ import org.springdoc.core.SpringDocConfigProperties; import org.springdoc.core.SpringDocConfiguration; +import org.springdoc.core.providers.ObjectMapperProvider; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -15,7 +16,12 @@ SpringDocConfiguration springDocConfiguration(){ } @Bean - public SpringDocConfigProperties springDocConfigProperties() { + SpringDocConfigProperties springDocConfigProperties() { return new SpringDocConfigProperties(); } + + @Bean + ObjectMapperProvider objectMapperProvider(SpringDocConfigProperties springDocConfigProperties){ + return new ObjectMapperProvider(springDocConfigProperties); + } } diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/AbstractSpringDocActuatorTest.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/AbstractSpringDocActuatorTest.java deleted file mode 100644 index c9c2febd4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/AbstractSpringDocActuatorTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package test.org.springdoc.api; - -import javax.annotation.PostConstruct; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.test.context.TestPropertySource; -import org.springframework.web.client.RestTemplate; - -@TestPropertySource(properties={ "management.endpoints.enabled-by-default=true" }) -public abstract class AbstractSpringDocActuatorTest extends AbstractCommonTest{ - - @LocalManagementPort - private int managementPort; - - @Autowired - private RestTemplateBuilder restTemplateBuilder; - - protected RestTemplate actuatorRestTemplate; - - @PostConstruct - void init() { - actuatorRestTemplate = restTemplateBuilder - .rootUri("http://localhost:" + this.managementPort).build(); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java deleted file mode 100644 index 373ebf4c0..000000000 --- a/springdoc-openapi-webmvc-core/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.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 - public 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-webmvc-core/src/test/java/test/org/springdoc/api/app1/ApiException.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ApiException.java deleted file mode 100644 index 2c061ad03..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ApiException.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.app1; - -public final class ApiException extends Exception { - - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - - private final int code; - - public ApiException(int code, String msg) { - super(msg); - this.code = code; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ApiOriginFilter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ApiOriginFilter.java deleted file mode 100644 index 8cf4e60c3..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ApiOriginFilter.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.app1; - -import java.io.IOException; - -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletResponse; - -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") -public class ApiOriginFilter implements javax.servlet.Filter { - @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); - } - - @Override - public void destroy() { - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ApiResponseMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ApiResponseMessage.java deleted file mode 100644 index 9683c3dec..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ApiResponseMessage.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 javax.xml.bind.annotation.XmlTransient; - -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") -@javax.xml.bind.annotation.XmlRootElement -public class ApiResponseMessage { - public static final int ERROR = 1; - - public static final int WARNING = 2; - - public static final int INFO = 3; - - public static final int OK = 4; - - public static final int TOO_BUSY = 5; - - int code; - - String type; - - String message; - - public ApiResponseMessage() { - } - - 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; - } - - @XmlTransient - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ErrorMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ErrorMessage.java deleted file mode 100644 index 63d9be499..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ErrorMessage.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; - -public class ErrorMessage { - - private String id; - - private String message; - - public ErrorMessage(String id, String message2) { - this.id = id; - this.message = message2; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ExceptionTranslator.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ExceptionTranslator.java deleted file mode 100644 index 7055ade87..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ExceptionTranslator.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; - -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; - -@ControllerAdvice -public class ExceptionTranslator { - - private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionTranslator.class); - - @ExceptionHandler({ RuntimeException.class }) - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public ResponseEntity handleRunTimeException(RuntimeException e) { - return error(HttpStatus.INTERNAL_SERVER_ERROR, e); - } - - - 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-webmvc-core/src/test/java/test/org/springdoc/api/app1/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/HelloController.java deleted file mode 100644 index 34e34b4d1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/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.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; - -@RestController -public class HelloController { - - @GetMapping(value = "/hello/{numTelco}") - @ResponseStatus(HttpStatus.I_AM_A_TEAPOT) - @Tag(name = "${prop.toto}") - 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-webmvc-core/src/test/java/test/org/springdoc/api/app1/HomeController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/HomeController.java deleted file mode 100644 index 35a187127..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/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.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app1/InventoryApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/InventoryApi.java deleted file mode 100644 index 386256b2a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/InventoryApi.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. - * - */ - -/** - * 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 javax.validation.Valid; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; - -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 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; - -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") -@Tag(name = "inventory") -public interface InventoryApi { - - @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); - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app1/InventoryApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/InventoryApiController.java deleted file mode 100644 index 787699a3f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/InventoryApiController.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.app1; - -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; - -import com.fasterxml.jackson.databind.ObjectMapper; -import io.swagger.v3.oas.annotations.Parameter; - -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; - -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") -@RestController -public class InventoryApiController implements InventoryApi { - - - @SuppressWarnings("unused") - private final ObjectMapper objectMapper; - - private final HttpServletRequest request; - - @org.springframework.beans.factory.annotation.Autowired - public InventoryApiController(ObjectMapper objectMapper, HttpServletRequest request) { - this.objectMapper = objectMapper; - this.request = request; - } - - 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); - } - - 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); - } - - public String getme(String language) { - return language; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/InventoryItem.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/InventoryItem.java deleted file mode 100644 index 2823d3929..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/InventoryItem.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 javax.validation.Valid; -import javax.validation.constraints.NotNull; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.validation.annotation.Validated; - -/** - * InventoryItem - */ -@Validated -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") -public class InventoryItem { - @JsonProperty("id") - private UUID id = null; - - @JsonProperty("name") - private String name = null; - - @JsonProperty("releaseDate") - private String releaseDate = null; - - @JsonProperty("manufacturer") - private Manufacturer manufacturer = null; - - public InventoryItem id(UUID id) { - this.id = id; - return this; - } - - /** - * Get id - * - * @return id - **/ - @Schema(example = "d290f1ee-6c54-4b01-90e6-d701748f0851", required = true) - @NotNull - - @Valid - public UUID getId() { - return id; - } - - public void setId(UUID id) { - this.id = id; - } - - public InventoryItem name(String name) { - this.name = name; - return this; - } - - /** - * Get name - * - * @return name - **/ - @Schema(example = "Widget Adapter", required = true) - @NotNull - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public InventoryItem releaseDate(String releaseDate) { - this.releaseDate = releaseDate; - return this; - } - - /** - * Get releaseDate - * - * @return releaseDate - **/ - @Schema(example = "2016-08-29T09:12:33.001Z", required = true) - @NotNull - - public String getReleaseDate() { - return releaseDate; - } - - public void setReleaseDate(String releaseDate) { - this.releaseDate = releaseDate; - } - - public InventoryItem manufacturer(Manufacturer manufacturer) { - this.manufacturer = manufacturer; - return this; - } - - /** - * Get manufacturer - * - * @return manufacturer - **/ - @Schema(required = true) - @NotNull - - @Valid - public Manufacturer getManufacturer() { - return manufacturer; - } - - public void setManufacturer(Manufacturer manufacturer) { - this.manufacturer = manufacturer; - } - - - @Override - public boolean equals(java.lang.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); - } - - @Override - public int hashCode() { - return Objects.hash(id, name, releaseDate, manufacturer); - } - - @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). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ItemController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ItemController.java deleted file mode 100644 index f0712b584..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ItemController.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.app1; - -import java.net.URI; -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import javax.validation.Valid; -import javax.validation.constraints.Size; - -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 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; - -@RestController -@Tag(name = "items") -public class ItemController { - - @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(); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app1/ItemDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ItemDTO.java deleted file mode 100644 index ca1edcb72..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ItemDTO.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.app1; - -import java.io.Serializable; - -/** - * @author bnasslahsen - */ -public 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; - - @Deprecated - private int deprecatedPrice; - - /** - * - */ - public ItemDTO() { - } - - /** - * @param description description - * @param price price - */ - public ItemDTO(final String description, final int price) { - this.description = description; - this.price = price; - } - - /** - * @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; - } - - /** - * @return - */ - public String getDescription() { - return description; - } - - /** - * @param description description - */ - public void setDescription(final String description) { - this.description = description; - } - - /** - * @return - */ - public String getItemID() { - return itemID; - } - - /** - * @param itemID itemID - */ - public void setItemID(final String itemID) { - this.itemID = itemID; - } - - /** - * @return - */ - public int getPrice() { - return price; - } - - /** - * @param price price - */ - public void setPrice(final int price) { - this.price = price; - } - - public int getDeprecatedPrice() { - return deprecatedPrice; - } - - public void setDeprecatedPrice(int deprecatedPrice) { - this.deprecatedPrice = deprecatedPrice; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ItemLightDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ItemLightDTO.java deleted file mode 100644 index 2f48dca8e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ItemLightDTO.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.app1; - -import java.io.Serializable; - -/** - * @author bnasslahsen - */ -public 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; - - @Deprecated - private int deprecatedPrice; - - /** - * - */ - public ItemLightDTO() { - } - - public ItemLightDTO(String description, int price) { - super(); - this.description = description; - this.price = price; - } - - /** - * @return - */ - public String getDescription() { - return description; - } - - /** - * @param description description - */ - public void setDescription(final String description) { - this.description = description; - } - - /** - * @return - */ - public int getPrice() { - return price; - } - - /** - * @param price price - */ - public void setPrice(final int price) { - this.price = price; - } - - public int getDeprecatedPrice() { - return deprecatedPrice; - } - - public void setDeprecatedPrice(int deprecatedPrice) { - this.deprecatedPrice = deprecatedPrice; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/Manufacturer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/Manufacturer.java deleted file mode 100644 index 8210ddb5b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/Manufacturer.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 javax.validation.constraints.NotNull; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.validation.annotation.Validated; - - -/** - * Manufacturer - */ -@Validated -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") -public class Manufacturer { - @JsonProperty("name") - private String name = null; - - @JsonProperty("homePage") - private String homePage = null; - - @JsonProperty("phone") - private String phone = null; - - public Manufacturer name(String name) { - this.name = name; - return this; - } - - /** - * Get name - * - * @return name - **/ - @Schema(example = "ACME Corporation", required = true) - @NotNull - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Manufacturer homePage(String homePage) { - this.homePage = homePage; - return this; - } - - /** - * Get homePage - * - * @return homePage - **/ - @Schema(example = "https://www.acme-corp.com") - - public String getHomePage() { - return homePage; - } - - public void setHomePage(String homePage) { - this.homePage = homePage; - } - - public Manufacturer phone(String phone) { - this.phone = phone; - return this; - } - - /** - * Get phone - * - * @return phone - **/ - @Schema(example = "408-867-5309") - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - - @Override - public boolean equals(java.lang.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); - } - - @Override - public int hashCode() { - return Objects.hash(name, homePage, phone); - } - - @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). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/PeopleRestService.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/PeopleRestService.java deleted file mode 100644 index a2ac1d9cb..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/PeopleRestService.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.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; - -@RestController -@Tag(name = "people") -public class PeopleRestService { - private Map people = new ConcurrentHashMap<>(); - - @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(); - } - - @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; - } - - @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(); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app1/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/PersonDTO.java deleted file mode 100644 index 766db47ab..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/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.app1; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java deleted file mode 100644 index 0f35dbe1b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.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.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; - -@TestPropertySource(properties = {"springdoc.default-produces-media-type=application/json", "prop.toto=tea"}) -public class SpringDocApp1Test extends AbstractSpringDocTest { - - @SpringBootApplication - 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("SpringShop API").version("v0") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app10/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app10/HelloController.java deleted file mode 100644 index 817f6333d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app10/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.app10; - -import java.nio.charset.Charset; -import java.util.Locale; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestAttribute; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/test") - public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, - String hello) { - } - - @GetMapping("/testreq") - public void testRequestAttribute(@RequestAttribute String sample, String s) { - } - - @GetMapping(value = {"/employee"}) - public void getEmployee(Charset test) { - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app10/SpringDocApp10Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app10/SpringDocApp10Test.java deleted file mode 100644 index df0aaefac..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app10/SpringDocApp10Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app100/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app100/HelloController.java deleted file mode 100644 index 255139f6e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app100/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.app100; - -import javax.validation.constraints.NotNull; - -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.tags.Tags; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@Tags(value = @Tag(name = "hello-ap1")) -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app100/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app100/PersonDTO.java deleted file mode 100644 index cd4854eb8..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app100/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.app100; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app100/SpringDocApp100Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app100/SpringDocApp100Test.java deleted file mode 100644 index 3d922a96b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app100/SpringDocApp100Test.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.app100; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp100Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app101/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app101/HelloController.java deleted file mode 100644 index 20beb44a0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app101/HelloController.java +++ /dev/null @@ -1,23 +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; - -@RestController -@RequestMapping("/hello") -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app101/HelloDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app101/HelloDTO.java deleted file mode 100644 index fb95f8167..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app101/HelloDTO.java +++ /dev/null @@ -1,21 +0,0 @@ -package test.org.springdoc.api.app101; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "${test.app101.schema.hello.description}") -public class HelloDTO { - - @Schema(description = "${test.app101.schema.hello.param.id.description}") - private String id; - - @JsonProperty("id") - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app101/SpringDocApp101Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app101/SpringDocApp101Test.java deleted file mode 100644 index 21a09a426..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app101/SpringDocApp101Test.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.app101; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.ActiveProfiles; - -@ActiveProfiles("101") -public class SpringDocApp101Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app102/InheritedRequestParams.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app102/InheritedRequestParams.java deleted file mode 100644 index bcb836f83..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app102/InheritedRequestParams.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app102; - -import javax.validation.constraints.NotBlank; - -import io.swagger.v3.oas.annotations.Parameter; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app102/RequestParams.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app102/RequestParams.java deleted file mode 100644 index 9814a8fcb..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app102/RequestParams.java +++ /dev/null @@ -1,124 +0,0 @@ -package test.org.springdoc.api.app102; - -import java.math.BigInteger; -import java.util.List; -import java.util.Optional; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.Parameter; - -import org.springframework.lang.Nullable; - -public class RequestParams { - - @Parameter(description = "string parameter") - @JsonIgnore - 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-webmvc-core/src/test/java/test/org/springdoc/api/app102/SpringDocApp102Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app102/SpringDocApp102Test.java deleted file mode 100644 index 019f521a8..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app102/SpringDocApp102Test.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app102; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp102Test extends AbstractSpringDocTest { - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app102/TestController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app102/TestController.java deleted file mode 100644 index 091e0b1b4..000000000 --- a/springdoc-openapi-webmvc-core/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.api.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-webmvc-core/src/test/java/test/org/springdoc/api/app103/ExampleBody.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app103/ExampleBody.java deleted file mode 100644 index 4d93ef747..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app103/ExampleBody.java +++ /dev/null @@ -1,23 +0,0 @@ -package test.org.springdoc.api.app103; - -public class ExampleBody { - private String stringParam; - - private int intParam; - - 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; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app103/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app103/HelloController.java deleted file mode 100644 index 7edca9279..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app103/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app103/SpringDocApp103Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app103/SpringDocApp103Test.java deleted file mode 100644 index 3fb2fa10e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app103/SpringDocApp103Test.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app103; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp103Test extends AbstractSpringDocTest { - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/CrudController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/CrudController.java deleted file mode 100644 index cedf257f1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/CrudController.java +++ /dev/null @@ -1,31 +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; - -@Controller -@SuppressWarnings("rawtypes") -public abstract class CrudController { - - @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; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app104/Design.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/Design.java deleted file mode 100644 index b205886ab..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/Design.java +++ /dev/null @@ -1,4 +0,0 @@ -package test.org.springdoc.api.app104; - -public class Design extends HavingPK { -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/DesignController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/DesignController.java deleted file mode 100644 index eaeab696f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/DesignController.java +++ /dev/null @@ -1,14 +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; - -@Tag(name = "design") -@Controller -@RequestMapping("/design") -public class DesignController extends CrudController { - - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/HavingPK.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/HavingPK.java deleted file mode 100644 index df5c3eb0b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/HavingPK.java +++ /dev/null @@ -1,4 +0,0 @@ -package test.org.springdoc.api.app104; - -public class HavingPK { -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/SpringDocApp104Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/SpringDocApp104Test.java deleted file mode 100644 index c1ba2a5bf..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app104/SpringDocApp104Test.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app104; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp104Test extends AbstractSpringDocTest { - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/SpringDocApp105Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/SpringDocApp105Test.java deleted file mode 100644 index 6540f3750..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/SpringDocApp105Test.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.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; - -@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", -}) -public class SpringDocApp105Test extends AbstractSpringDocTest { - - public static String className; - - @Test - public 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 - public 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 - public 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 - public 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)); - } - - - @SpringBootApplication - 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("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-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/ApiUtil.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/ApiUtil.java deleted file mode 100644 index e85b410a4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.api; - -import java.io.IOException; - -import javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/ExceptionTranslator.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/ExceptionTranslator.java deleted file mode 100644 index 2f0a1b392..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.api; - -import java.util.Map; - -import javax.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("javax.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); - return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/HomeController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/HomeController.java deleted file mode 100644 index b3b04c2f4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/pet/PetApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/pet/PetApi.java deleted file mode 100644 index c2f65c055..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/pet/PetApi.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. - * - */ - -/** - * 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 javax.validation.Valid; -import javax.validation.constraints.NotNull; - -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 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; - -@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 { - - 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-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiController.java deleted file mode 100644 index 00462427c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.api.pet; - -import java.util.Optional; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiDelegate.java deleted file mode 100644 index f57549c41..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiDelegate.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 javax.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. - */ -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiDelegateImpl.java deleted file mode 100644 index 754e78174..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.api.pet; - -import org.springframework.stereotype.Service; - -@Service -public class PetApiDelegateImpl implements PetApiDelegate { - - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/store/StoreApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/store/StoreApi.java deleted file mode 100644 index bdefa7f04..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/store/StoreApi.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT 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 javax.validation.Valid; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; - -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 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; - -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiController.java deleted file mode 100644 index 5caceceda..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.api.store; - -import java.util.Optional; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiDelegate.java deleted file mode 100644 index fe317cc0c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.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. - */ -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiDelegateImpl.java deleted file mode 100644 index 9453bd526..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.api.store; - -import org.springframework.stereotype.Service; - -@Service -public class StoreApiDelegateImpl implements StoreApiDelegate { - - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/user/UserApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/user/UserApi.java deleted file mode 100644 index e12f1ca6b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/user/UserApi.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. - * - */ - -/** - * 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 javax.validation.Valid; -import javax.validation.constraints.NotNull; - -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 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; - -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/user/UserApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/user/UserApiController.java deleted file mode 100644 index 85fadaf70..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.api.user; - -import java.util.Optional; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/user/UserApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/user/UserApiDelegate.java deleted file mode 100644 index 542c67087..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.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. - */ -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/user/UserApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/api/user/UserApiDelegateImpl.java deleted file mode 100644 index 61a88582c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.api.user; - -import org.springframework.stereotype.Service; - -@Service -public class UserApiDelegateImpl implements UserApiDelegate { - - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Body.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Body.java deleted file mode 100644 index f60340164..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Body1.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Body1.java deleted file mode 100644 index 599ec662e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Category.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Category.java deleted file mode 100644 index 7605baf0b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/ModelApiResponse.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/ModelApiResponse.java deleted file mode 100644 index 83616544c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Order.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Order.java deleted file mode 100644 index e338e2fce..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.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; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Pet.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Pet.java deleted file mode 100644 index a4c821fb8..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Pet.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 javax.validation.constraints.NotNull; - -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 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-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Tag.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/Tag.java deleted file mode 100644 index 5ee7098db..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.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-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/model/User.java deleted file mode 100644 index abbcb9bf0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app105/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.app105.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-webmvc-core/src/test/java/test/org/springdoc/api/app106/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app106/HelloController.java deleted file mode 100644 index fa3a56302..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app106/HelloController.java +++ /dev/null @@ -1,31 +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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app106/SpringDocApp106Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app106/SpringDocApp106Test.java deleted file mode 100644 index d4a95a94d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app106/SpringDocApp106Test.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app106; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp106Test extends AbstractSpringDocTest { - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app107/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app107/HelloController.java deleted file mode 100644 index b9f855ef4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app107/HelloController.java +++ /dev/null @@ -1,36 +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; - -@RestController -public class HelloController { - - @GetMapping(path = "/entity-b", produces = { "application/json", "application/xml" }) - public EntityB getEntityB() { - return new EntityB(); - } - - public class EntityB { - - @Schema(required = true) - @JsonProperty("fieldB") - private String fieldB; - - @Schema(required = true) - @JsonProperty("entityA") - private EntityA entityA; - //Getters and setters... - } - - public class EntityA { - @Schema(required = true) - @JsonProperty("fieldA") - private String fieldA; - //Getters and setters... - } -} - diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app107/SpringDocApp107Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app107/SpringDocApp107Test.java deleted file mode 100644 index e6b630bfc..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app107/SpringDocApp107Test.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app107; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp107Test extends AbstractSpringDocTest { - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app108/ActionResult.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app108/ActionResult.java deleted file mode 100644 index e567e6d32..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app108/ActionResult.java +++ /dev/null @@ -1,64 +0,0 @@ -package test.org.springdoc.api.app108; - -public class ActionResult { - - protected T value; - - protected boolean success; - - protected String errorCode; - - protected String message; - - protected Object errorValue; - - protected String targetUrl; - - public T getValue() { - return value; - } - - public void setValue(T value) { - this.value = value; - } - - public boolean isSuccess() { - return success; - } - - public void setSuccess(boolean success) { - this.success = success; - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public Object getErrorValue() { - return errorValue; - } - - public void setErrorValue(Object errorValue) { - this.errorValue = errorValue; - } - - public String getTargetUrl() { - return targetUrl; - } - - public void setTargetUrl(String targetUrl) { - this.targetUrl = targetUrl; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app108/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app108/HelloController.java deleted file mode 100644 index 44b609b85..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app108/HelloController.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app108; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @PostMapping - public ActionResult update(String toto) { - return null; - } -} - diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app108/SpringDocApp108Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app108/SpringDocApp108Test.java deleted file mode 100644 index 2c1e10bfa..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app108/SpringDocApp108Test.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app108; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp108Test extends AbstractSpringDocTest { - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app109/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app109/HelloController.java deleted file mode 100644 index 37b4da90d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app109/HelloController.java +++ /dev/null @@ -1,25 +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; - -@RestController -public class HelloController { - - @GetMapping("/api/v1/resource") - public Resource getResource() { - return new ByteArrayResource(new 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-webmvc-core/src/test/java/test/org/springdoc/api/app109/SpringDocApp109Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app109/SpringDocApp109Test.java deleted file mode 100644 index c560fc4b7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app109/SpringDocApp109Test.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app109; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp109Test extends AbstractSpringDocTest { - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app11/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app11/HelloController.java deleted file mode 100644 index be04d5150..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app11/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.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; - -@RestController -public class HelloController { - - @PostMapping(path = "/documents", consumes = "multipart/form-data") - public ResponseEntity uploadDocuments(@RequestPart("doc") List multipartFiles) { - return null; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app11/SpringDocApp11Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app11/SpringDocApp11Test.java deleted file mode 100644 index 5345f214b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app11/SpringDocApp11Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app110/ErrorMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/ErrorMessage.java deleted file mode 100644 index 9fb963a95..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/ErrorMessage.java +++ /dev/null @@ -1,34 +0,0 @@ -package test.org.springdoc.api.app110; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - - -public class ErrorMessage { - - private List errors; - - public ErrorMessage() { - } - - public ErrorMessage(List errors) { - this.errors = errors; - } - - public ErrorMessage(String error) { - this(Collections.singletonList(error)); - } - - public ErrorMessage(String... errors) { - this(Arrays.asList(errors)); - } - - public List getErrors() { - return errors; - } - - public void setErrors(List errors) { - this.errors = errors; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/GlobalControllerAdvice.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/GlobalControllerAdvice.java deleted file mode 100644 index 6f81f47a0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/GlobalControllerAdvice.java +++ /dev/null @@ -1,131 +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 javax.validation.ConstraintViolation; -import javax.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; - - -@ControllerAdvice(assignableTypes = PersonController.class) -public 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); - - @ExceptionHandler(Throwable.class) - @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) - public ResponseEntity problem(final Throwable e) { - String message = e.getMessage(); - //might actually prefer to use a geeric mesasge - - 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); - } - - - @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); - } - - @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); - } - - @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); - } - - - @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); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app110/Person.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/Person.java deleted file mode 100644 index 388928874..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/Person.java +++ /dev/null @@ -1,93 +0,0 @@ -package test.org.springdoc.api.app110; - -import javax.validation.constraints.Email; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; - -import org.hibernate.validator.constraints.CreditCardNumber; - - -public class Person { - private long id; - - private String firstName; - - @NotNull - @NotBlank - @Size(max = 10) - private String lastName; - - @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") - private String email; - - @Email() - private String email1; - - @Min(18) - @Max(30) - private int age; - - @CreditCardNumber - private String creditCardNumber; - - public String getCreditCardNumber() { - return creditCardNumber; - } - - public void setCreditCardNumber(String creditCardNumber) { - this.creditCardNumber = creditCardNumber; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getEmail1() { - return email1; - } - - public void setEmail1(String email1) { - this.email1 = email1; - } - - @Size(min = 2) - 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 getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/PersonController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/PersonController.java deleted file mode 100644 index 1c867a033..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/PersonController.java +++ /dev/null @@ -1,51 +0,0 @@ -package test.org.springdoc.api.app110; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.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; - -@RestController -@Validated -public class PersonController { - private Random ran = new Random(); - - @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; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app110/PersonController2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/PersonController2.java deleted file mode 100644 index 560925069..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/PersonController2.java +++ /dev/null @@ -1,51 +0,0 @@ -package test.org.springdoc.api.app110; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.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; - -@RestController -@Validated -public class PersonController2 { - private Random ran = new Random(); - - @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; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app110/Problem.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/Problem.java deleted file mode 100644 index 81f2d0547..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/Problem.java +++ /dev/null @@ -1,35 +0,0 @@ -package test.org.springdoc.api.app110; - -public class Problem { - - private String logRef; - - private String message; - - public Problem(String logRef, String message) { - super(); - this.logRef = logRef; - this.message = message; - } - - public Problem() { - super(); - - } - - public String getLogRef() { - return logRef; - } - - public void setLogRef(String logRef) { - this.logRef = logRef; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/SpringDocApp110Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/SpringDocApp110Test.java deleted file mode 100644 index 128476c4e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app110/SpringDocApp110Test.java +++ /dev/null @@ -1,33 +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; - -@TestPropertySource(properties = { - "application-description=description", - "application-version=v1" }) -public class SpringDocApp110Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app111/ErrorMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/ErrorMessage.java deleted file mode 100644 index c68f38c56..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/ErrorMessage.java +++ /dev/null @@ -1,34 +0,0 @@ -package test.org.springdoc.api.app111; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - - -public class ErrorMessage { - - private List errors; - - public ErrorMessage() { - } - - public ErrorMessage(List errors) { - this.errors = errors; - } - - public ErrorMessage(String error) { - this(Collections.singletonList(error)); - } - - public ErrorMessage(String... errors) { - this(Arrays.asList(errors)); - } - - public List getErrors() { - return errors; - } - - public void setErrors(List errors) { - this.errors = errors; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/GlobalControllerAdvice.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/GlobalControllerAdvice.java deleted file mode 100644 index 74f74d6db..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/GlobalControllerAdvice.java +++ /dev/null @@ -1,131 +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 javax.validation.ConstraintViolation; -import javax.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; - - -@ControllerAdvice(basePackages = "test.org.springdoc.api.appzzz") -public 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); - - @ExceptionHandler(Throwable.class) - @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) - public ResponseEntity problem(final Throwable e) { - String message = e.getMessage(); - //might actually prefer to use a geeric mesasge - - 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); - } - - - @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); - } - - @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); - } - - @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); - } - - - @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); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app111/Person.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/Person.java deleted file mode 100644 index e606bdb43..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/Person.java +++ /dev/null @@ -1,93 +0,0 @@ -package test.org.springdoc.api.app111; - -import javax.validation.constraints.Email; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; - -import org.hibernate.validator.constraints.CreditCardNumber; - - -public class Person { - private long id; - - private String firstName; - - @NotNull - @NotBlank - @Size(max = 10) - private String lastName; - - @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") - private String email; - - @Email() - private String email1; - - @Min(18) - @Max(30) - private int age; - - @CreditCardNumber - private String creditCardNumber; - - public String getCreditCardNumber() { - return creditCardNumber; - } - - public void setCreditCardNumber(String creditCardNumber) { - this.creditCardNumber = creditCardNumber; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getEmail1() { - return email1; - } - - public void setEmail1(String email1) { - this.email1 = email1; - } - - @Size(min = 2) - 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 getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/PersonController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/PersonController.java deleted file mode 100644 index d1f1db665..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/PersonController.java +++ /dev/null @@ -1,51 +0,0 @@ -package test.org.springdoc.api.app111; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.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; - -@RestController -@Validated -public class PersonController { - private Random ran = new Random(); - - @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; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app111/PersonController2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/PersonController2.java deleted file mode 100644 index 6ca0a77f2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/PersonController2.java +++ /dev/null @@ -1,51 +0,0 @@ -package test.org.springdoc.api.app111; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.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; - -@RestController -@Validated -public class PersonController2 { - private Random ran = new Random(); - - @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; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app111/Problem.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/Problem.java deleted file mode 100644 index ba8de5005..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/Problem.java +++ /dev/null @@ -1,35 +0,0 @@ -package test.org.springdoc.api.app111; - -public class Problem { - - private String logRef; - - private String message; - - public Problem(String logRef, String message) { - super(); - this.logRef = logRef; - this.message = message; - } - - public Problem() { - super(); - - } - - public String getLogRef() { - return logRef; - } - - public void setLogRef(String logRef) { - this.logRef = logRef; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/SpringDocApp111Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/SpringDocApp111Test.java deleted file mode 100644 index f35061a4f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app111/SpringDocApp111Test.java +++ /dev/null @@ -1,32 +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; - -@TestPropertySource(properties = { - "application-description=description", - "application-version=v1" }) -public class SpringDocApp111Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app112/ErrorMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/ErrorMessage.java deleted file mode 100644 index 89742b247..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/ErrorMessage.java +++ /dev/null @@ -1,34 +0,0 @@ -package test.org.springdoc.api.app112; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - - -public class ErrorMessage { - - private List errors; - - public ErrorMessage() { - } - - public ErrorMessage(List errors) { - this.errors = errors; - } - - public ErrorMessage(String error) { - this(Collections.singletonList(error)); - } - - public ErrorMessage(String... errors) { - this(Arrays.asList(errors)); - } - - public List getErrors() { - return errors; - } - - public void setErrors(List errors) { - this.errors = errors; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/GlobalControllerAdvice.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/GlobalControllerAdvice.java deleted file mode 100644 index 2078ca318..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/GlobalControllerAdvice.java +++ /dev/null @@ -1,131 +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 javax.validation.ConstraintViolation; -import javax.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; - - -@ControllerAdvice(basePackages = "test.org.springdoc.api.app112.sample") -public 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); - - @ExceptionHandler(Throwable.class) - @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) - public ResponseEntity problem(final Throwable e) { - String message = e.getMessage(); - //might actually prefer to use a geeric mesasge - - 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); - } - - - @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); - } - - @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); - } - - @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); - } - - - @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); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app112/Person.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/Person.java deleted file mode 100644 index e110830d7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/Person.java +++ /dev/null @@ -1,93 +0,0 @@ -package test.org.springdoc.api.app112; - -import javax.validation.constraints.Email; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; - -import org.hibernate.validator.constraints.CreditCardNumber; - - -public class Person { - private long id; - - private String firstName; - - @NotNull - @NotBlank - @Size(max = 10) - private String lastName; - - @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") - private String email; - - @Email() - private String email1; - - @Min(18) - @Max(30) - private int age; - - @CreditCardNumber - private String creditCardNumber; - - public String getCreditCardNumber() { - return creditCardNumber; - } - - public void setCreditCardNumber(String creditCardNumber) { - this.creditCardNumber = creditCardNumber; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getEmail1() { - return email1; - } - - public void setEmail1(String email1) { - this.email1 = email1; - } - - @Size(min = 2) - 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 getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/PersonController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/PersonController.java deleted file mode 100644 index c320cf9b2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/PersonController.java +++ /dev/null @@ -1,51 +0,0 @@ -package test.org.springdoc.api.app112; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.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; - -@RestController -@Validated -public class PersonController { - private Random ran = new Random(); - - @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; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app112/Problem.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/Problem.java deleted file mode 100644 index 318621e67..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/Problem.java +++ /dev/null @@ -1,35 +0,0 @@ -package test.org.springdoc.api.app112; - -public class Problem { - - private String logRef; - - private String message; - - public Problem(String logRef, String message) { - super(); - this.logRef = logRef; - this.message = message; - } - - public Problem() { - super(); - - } - - public String getLogRef() { - return logRef; - } - - public void setLogRef(String logRef) { - this.logRef = logRef; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/SpringDocApp112Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/SpringDocApp112Test.java deleted file mode 100644 index 4984fc051..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/SpringDocApp112Test.java +++ /dev/null @@ -1,32 +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; - -@TestPropertySource(properties = { - "application-description=description", - "application-version=v1" }) -public class SpringDocApp112Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app112/sample/PersonController2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/sample/PersonController2.java deleted file mode 100644 index a4c88f28e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app112/sample/PersonController2.java +++ /dev/null @@ -1,53 +0,0 @@ -package test.org.springdoc.api.app112.sample; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -import test.org.springdoc.api.app112.Person; - -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; - -@RestController -@Validated -public class PersonController2 { - private Random ran = new Random(); - - @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; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app113/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app113/HelloController.java deleted file mode 100644 index cd2e640fc..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app113/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.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; - -@RestController -public class HelloController { - - @PostMapping("/lol") - public void test(@RequestBody(required = false) Body body) { - } - - @PostMapping("/lol2") - public void test2(@RequestBody Optional body) { - } - - public class Body { - public String field; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app113/SpringDocApp113Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app113/SpringDocApp113Test.java deleted file mode 100644 index 430158df5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app113/SpringDocApp113Test.java +++ /dev/null @@ -1,12 +0,0 @@ -package test.org.springdoc.api.app113; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -public class SpringDocApp113Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app114/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app114/HelloController.java deleted file mode 100644 index 2daf2a682..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app114/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.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; - -@RestController -public class HelloController { - - @PostMapping(value = "/foos1", consumes = MediaType.APPLICATION_JSON_VALUE) - MonetaryAmount getCurrency(@RequestBody CarDTO carDTO) { - return carDTO.price; - } - - class CarDTO { - @JsonProperty("price") - MonetaryAmount price; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app114/SpringDocApp114Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app114/SpringDocApp114Test.java deleted file mode 100644 index cace0b3a2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app114/SpringDocApp114Test.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app114; - -import javax.money.MonetaryAmount; - -import org.springdoc.core.SpringDocUtils; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -public class SpringDocApp114Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - - static { - SpringDocUtils.getConfig().replaceWithClass(MonetaryAmount.class, org.springdoc.core.converters.models.MonetaryAmount.class); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app115/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app115/HelloController.java deleted file mode 100644 index 0cf36c29a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app115/HelloController.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.app115; - -import java.time.Duration; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app115/JavaTimeOperationCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app115/JavaTimeOperationCustomizer.java deleted file mode 100644 index ff0bd2b48..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app115/JavaTimeOperationCustomizer.java +++ /dev/null @@ -1,32 +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; - -@Component -public class JavaTimeOperationCustomizer implements OperationCustomizer { - @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-webmvc-core/src/test/java/test/org/springdoc/api/app115/SpringDocApp115Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app115/SpringDocApp115Test.java deleted file mode 100644 index baf590273..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app115/SpringDocApp115Test.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app115; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -public class SpringDocApp115Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app116/FooErrorHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app116/FooErrorHandler.java deleted file mode 100644 index dcfd555a9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app116/FooErrorHandler.java +++ /dev/null @@ -1,15 +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; - -@ControllerAdvice(assignableTypes = HelloController.class) -public class FooErrorHandler { - - @ExceptionHandler - public ResponseEntity storeAssignmentPublishingError(Exception e) { - return new ResponseEntity<>("foo", HttpStatus.INTERNAL_SERVER_ERROR); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app116/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app116/HelloController.java deleted file mode 100644 index 00f2f7875..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app116/HelloController.java +++ /dev/null @@ -1,23 +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; - -@RestController -@RequestMapping("/api") -@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) -public class HelloController { - - @PostMapping("/foo") - public String create(@RequestBody String foo) { - return "foo"; - } -} - - diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app116/SpringDocApp116Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app116/SpringDocApp116Test.java deleted file mode 100644 index 097423b56..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app116/SpringDocApp116Test.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app116; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -public class SpringDocApp116Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app117/HelloApplication.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app117/HelloApplication.java deleted file mode 100644 index 99db6314f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app117/HelloApplication.java +++ /dev/null @@ -1,157 +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 javax.servlet.FilterChain; -import javax.servlet.GenericFilter; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; - -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.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; - -@Configuration -public class HelloApplication { - - @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(); - } -} - -@Component -class SimpleFilter extends GenericFilter { - - @Override - public void doFilter(ServletRequest req, ServletResponse res, - FilterChain filterChain) throws IOException, ServletException { - filterChain.doFilter(req, res); - } -} - -@Component -class PersonHandler { - - private final PersonService personService; - - PersonHandler(PersonService personService) { - this.personService = personService; - } - - ServerResponse handleGetAllPeople(ServerRequest serverRequest) { - return ok().body(personService.all()); - } - - 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); - } - - ServerResponse handleGetPersonById(ServerRequest r) { - return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); - } -} - -@RestController -class GreetingsRestController { - - @GetMapping("/greet/{name}") - String greet(@PathVariable String name) { - return "hello " + name + "!"; - } -} - -@Service -class PersonService { - - private final AtomicLong counter = new AtomicLong(); - - 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)); - - - Person save(Person p) { - Person person = new Person(counter.incrementAndGet(), p.getName()); - this.people.add(person); - return person; - } - - Set all() { - return this.people; - } - - 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!")); - } - -} - -class Person { - - public Person(Long id, String name) { - this.id = id; - this.name = name; - } - - 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; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app117/SpringDocApp117Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app117/SpringDocApp117Test.java deleted file mode 100644 index 24b9071f9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app117/SpringDocApp117Test.java +++ /dev/null @@ -1,12 +0,0 @@ -package test.org.springdoc.api.app117; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -public class SpringDocApp117Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app118/AbstractParent.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app118/AbstractParent.java deleted file mode 100644 index 679f24ba4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app118/AbstractParent.java +++ /dev/null @@ -1,47 +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; - -@JsonTypeInfo(use = Id.NAME, property = "type") -@JsonSubTypes({ - @Type(ChildOfAbstract1.class), - @Type(ChildOfAbstract2.class) -}) -public abstract class AbstractParent { - private int id; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } -} - -class ChildOfAbstract1 extends AbstractParent { - private String abstrachChild1Param; - - public String getAbstrachChild1Param() { - return abstrachChild1Param; - } - - public void setAbstrachChild1Param(String abstrachChild1Param) { - this.abstrachChild1Param = abstrachChild1Param; - } -} - -class ChildOfAbstract2 extends AbstractParent { - private String abstractChild2Param; - - public String getAbstractChild2Param() { - return abstractChild2Param; - } - - public void setAbstractChild2Param(String abstractChild2Param) { - this.abstractChild2Param = abstractChild2Param; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app118/ConcreteParent.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app118/ConcreteParent.java deleted file mode 100644 index 217de4c9f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app118/ConcreteParent.java +++ /dev/null @@ -1,47 +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; - -@JsonTypeInfo(use = Id.NAME, property = "type") -@JsonSubTypes({ - @Type(ChildOfConcrete1.class), - @Type(ChildOfConcrete2.class) -}) -public class ConcreteParent { - private int id; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } -} - -class ChildOfConcrete1 extends ConcreteParent { - private String concreteChild1Param; - - public String getConcreteChild1Param() { - return concreteChild1Param; - } - - public void setConcreteChild1Param(String concreteChild1Param) { - this.concreteChild1Param = concreteChild1Param; - } -} - -class ChildOfConcrete2 extends ConcreteParent { - private String concreteChild2Param; - - public String getConcreteChild2Param() { - return concreteChild2Param; - } - - public void setConcreteChild2Param(String concreteChild2Param) { - this.concreteChild2Param = concreteChild2Param; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app118/Controller.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app118/Controller.java deleted file mode 100644 index ed7525b33..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app118/Controller.java +++ /dev/null @@ -1,44 +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; - -@RestController -@RequestMapping("class-hierarchy") -public class Controller { - @PostMapping("abstract-parent") - public Response abstractParent(@RequestBody AbstractParent payload) { - return null; - } - - @PostMapping("concrete-parent") - public Response concreteParent(@RequestBody ConcreteParent payload) { - return null; - } -} - -class Response { - AbstractParent abstractParent; - - List concreteParents; - - public AbstractParent getAbstractParent() { - return abstractParent; - } - - public void setAbstractParent(AbstractParent abstractParent) { - this.abstractParent = abstractParent; - } - - public List getConcreteParents() { - return concreteParents; - } - - public void setConcreteParents(List concreteParents) { - this.concreteParents = concreteParents; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app118/SpringDocApp118Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app118/SpringDocApp118Test.java deleted file mode 100644 index 8c12290db..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app118/SpringDocApp118Test.java +++ /dev/null @@ -1,12 +0,0 @@ -package test.org.springdoc.api.app118; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -public class SpringDocApp118Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/HelloController.java deleted file mode 100644 index b94ead0b3..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app119/JsonRequest.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/JsonRequest.java deleted file mode 100644 index 0c3084daf..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/JsonRequest.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app119; - -public class JsonRequest { - - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/SpringDocApp119Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/SpringDocApp119Test.java deleted file mode 100644 index e56979af0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/SpringDocApp119Test.java +++ /dev/null @@ -1,12 +0,0 @@ -package test.org.springdoc.api.app119; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -public class SpringDocApp119Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app12/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app12/HelloController.java deleted file mode 100644 index 1dd6d5017..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app12/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app12/SpringDocApp12Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app12/SpringDocApp12Test.java deleted file mode 100644 index 8c36a7d82..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app12/SpringDocApp12Test.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.app12; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp12Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/AccountId.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/AccountId.java deleted file mode 100644 index 0cb803f58..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/AccountId.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.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; - -@Target({PARAMETER, METHOD, ANNOTATION_TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Parameter(description = "non alias description") -public @interface AccountId { - - @AliasFor(annotation = Parameter.class, value = "name") - String name() default ""; - - @AliasFor(annotation = Parameter.class, value = "example") - String example() default "123456"; - - @AliasFor(annotation = Parameter.class, value = "in") - ParameterIn in() default ParameterIn.DEFAULT; - - @AliasFor(annotation = Parameter.class, value = "schema") - Schema schema() default @Schema(); -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/SpringDocApp120Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/SpringDocApp120Test.java deleted file mode 100644 index e942f5476..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/SpringDocApp120Test.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.app120; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -public class SpringDocApp120Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app121/InheritedRequestParams.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app121/InheritedRequestParams.java deleted file mode 100644 index f99c0b5a5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app121/InheritedRequestParams.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app121; - -import javax.validation.constraints.NotBlank; - -import io.swagger.v3.oas.annotations.Parameter; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app121/RequestParams.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app121/RequestParams.java deleted file mode 100644 index 5f2a0e4df..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app121/RequestParams.java +++ /dev/null @@ -1,119 +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; - - -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; - - 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; - } - - public String getIntParam3() { - return intParam3; - } - - public void setIntParam3(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-webmvc-core/src/test/java/test/org/springdoc/api/app121/TestController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app121/TestController.java deleted file mode 100644 index a5e827717..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app121/TestController.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app121; - -import org.springdoc.api.annotations.ParameterObject; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class TestController { - - @PostMapping("test") - public InheritedRequestParams getTest(@RequestParam String param, @ParameterObject InheritedRequestParams requestParams) { - return requestParams; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/BaseController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/BaseController.java deleted file mode 100644 index 5ca060260..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/BaseController.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.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; - -@RestController -public abstract class BaseController { - - @PostMapping - @Operation(summary = "create") - public ResponseEntity create(@RequestBody Wrapper payload) { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app123/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app123/HelloController.java deleted file mode 100644 index 7161342e7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app123/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app123/MyExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app123/MyExceptionHandler.java deleted file mode 100644 index 758c3dbc9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app123/MyExceptionHandler.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.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; - -@RestControllerAdvice -public class MyExceptionHandler { - - @ExceptionHandler(IllegalArgumentException.class) - @ApiResponse(responseCode = "404", description = "Not here", content = @Content) - @ResponseStatus(HttpStatus.NOT_FOUND) - public void bad(IllegalArgumentException e) { - - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app124/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app124/HelloController.java deleted file mode 100644 index cea3dea84..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app124/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.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; - -@RestController -public class HelloController { - - @ExceptionHandler(IllegalArgumentException.class) - @ApiResponse(responseCode = "404", description = "Not here", content = @Content) - @ResponseStatus(HttpStatus.NOT_FOUND) - public void bad(IllegalArgumentException e) { - - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app124/MyExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app124/MyExceptionHandler.java deleted file mode 100644 index cb434909c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app124/MyExceptionHandler.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.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; - -@RestControllerAdvice -public class MyExceptionHandler { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app125/DeprecatedEntity.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app125/DeprecatedEntity.java deleted file mode 100644 index 09b7ee6c6..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app125/DeprecatedEntity.java +++ /dev/null @@ -1,35 +0,0 @@ -package test.org.springdoc.api.app125; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app125/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app125/HelloController.java deleted file mode 100644 index ccd78c23f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app125/HelloController.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.org.springdoc.api.app125; - -import javax.validation.constraints.NotNull; - -import org.springdoc.api.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-webmvc-core/src/test/java/test/org/springdoc/api/app126/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app126/HelloController.java deleted file mode 100644 index 1ddcf5991..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app126/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.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; - -@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)}) }) -public class HelloController { - - private static final Collection CURRENCIES = new ArrayList<>(); - static { - CURRENCIES.add("EUR"); - CURRENCIES.add("USD"); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app126/Problem.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app126/Problem.java deleted file mode 100644 index 400ef6314..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app126/Problem.java +++ /dev/null @@ -1,73 +0,0 @@ -package test.org.springdoc.api.app126; - -import java.net.URI; -import java.util.Collections; -import java.util.Map; - -public interface Problem { - - 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-webmvc-core/src/test/java/test/org/springdoc/api/app126/SecurityProblemResponsesConfiguration.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app126/SecurityProblemResponsesConfiguration.java deleted file mode 100644 index a6b34739f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app126/SecurityProblemResponsesConfiguration.java +++ /dev/null @@ -1,54 +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 -public class SecurityProblemResponsesConfiguration { - - private static final String HTTP_401_NO_TOKEN = "http401NoToken"; - private static final String HTTP_401_BAD_TOKEN = "http401BadToken"; - private static final String HTTP_403 = "http403"; - public static final String UNAUTHORIZED_401_NO_TOKEN_RESPONSE_REF = "#/components/responses/" + HTTP_401_NO_TOKEN; - public static final String UNAUTHORIZED_401_BAD_TOKEN_RESPONSE_REF = "#/components/responses/" + HTTP_401_BAD_TOKEN; - public static final String FORBIDDEN_403_RESPONSE_REF = "#/components/responses/" + HTTP_403; - - @Bean - public Map.Entry http401NoTokenResponse() throws IOException { - return simpleResponse(HTTP_401_NO_TOKEN, "Invalid authentication."); - } - - @Bean - public Map.Entry http401BadTokenResponse() throws IOException { - return simpleResponse(HTTP_401_BAD_TOKEN, "Invalid authentication."); - } - - @Bean - public Map.Entry http403Example() throws IOException { - return simpleResponse(HTTP_403, "Missing authorities."); - } - - 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-webmvc-core/src/test/java/test/org/springdoc/api/app127/AbstractObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/AbstractObject.java deleted file mode 100644 index 25f117f15..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/AbstractObject.java +++ /dev/null @@ -1,31 +0,0 @@ -package test.org.springdoc.api.app127; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@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 { - - private final ConcreteType type; - private final String name; - - protected AbstractObject(ConcreteType type, String name) { - this.type = type; - this.name = name; - } - - public ConcreteType getType() { - return type; - } - - public String getName() { - return name; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/ConcreteObjectA.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/ConcreteObjectA.java deleted file mode 100644 index 0f9d5af7d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/ConcreteObjectA.java +++ /dev/null @@ -1,15 +0,0 @@ -package test.org.springdoc.api.app127; - -public class ConcreteObjectA extends AbstractObject { - - private final String description; - - public ConcreteObjectA(String name, String description) { - super(ConcreteType.TYPE_A, name); - this.description = description; - } - - public String getDescription() { - return description; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/ConcreteType.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/ConcreteType.java deleted file mode 100644 index ec3a72121..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/ConcreteType.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app127; - -public enum ConcreteType { - TYPE_A("Type A"), - TYPE_B("Type B"); - - private final String name; - - ConcreteType(String name) { - this.name = name; - } - - public String getName() { - return name; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/Controller.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/Controller.java deleted file mode 100644 index f73d77a2a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/Controller.java +++ /dev/null @@ -1,28 +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; - -@RestController -public class Controller { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app127/Umbrella.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/Umbrella.java deleted file mode 100644 index f98c15683..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/Umbrella.java +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app127; - -import io.swagger.v3.oas.annotations.media.Schema; - -public class Umbrella { - - @Schema(description = "This reference to abstract class causes weird YAML tag to be added", anyOf = ConcreteObjectA.class) - private final AbstractObject object; - - public Umbrella(AbstractObject object) { - this.object = object; - } - - public AbstractObject getObject() { - return object; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app128/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app128/HelloController.java deleted file mode 100644 index ea8209be8..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app129/ActualReturnedEntity.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app129/ActualReturnedEntity.java deleted file mode 100644 index f8a5c3fdf..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app129/ActualReturnedEntity.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app129; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class ActualReturnedEntity { - - @JsonProperty - String result; - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app129/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app129/HelloController.java deleted file mode 100644 index 88cc99740..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app129/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.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; - -@RestController -@RequestMapping(path = "/api", headers = {"userId", "registrationId"}) -public class HelloController { - - @PostMapping("/test") - @ApiResponses({@ApiResponse(responseCode = "200")}) - public DeferredResult> update( - @RequestBody ActualReturnedEntity entity) throws Exception { - return null; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app129/OperationResponse.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app129/OperationResponse.java deleted file mode 100644 index 9dc4212b2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app129/OperationResponse.java +++ /dev/null @@ -1,9 +0,0 @@ -package test.org.springdoc.api.app129; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class OperationResponse { - - @JsonProperty - String operationResult; -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app13/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app13/HelloController.java deleted file mode 100644 index e78d85c84..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app13/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.app13; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/persons") - public String persons(final PersonDTO dto) { - return "OK"; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app13/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app13/PersonDTO.java deleted file mode 100644 index f81325808..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app13/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.app13; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app13/SpringDocApp13Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app13/SpringDocApp13Test.java deleted file mode 100644 index bc7621ecd..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app13/SpringDocApp13Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app130/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app130/HelloController.java deleted file mode 100644 index f9340ba42..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app130/HelloController.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.app130; - -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 { - - @PostMapping(value = "/values/data") - TrackerData list(TrackerData toto) { - return toto; - } - - @GetMapping(value = "/values/datakk") - TrackerData get(TrackerData toto) { - return toto; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app130/TrackerData.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app130/TrackerData.java deleted file mode 100644 index d01bd60ba..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app130/TrackerData.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 java.time.Instant; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.Hidden; -import io.swagger.v3.oas.annotations.media.Schema; - -@Hidden -public class TrackerData { - - @JsonProperty("trackerId") - String trackerId; - - @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") - @JsonProperty("timestamp") - Instant timestamp; - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app131/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app131/HelloController.java deleted file mode 100644 index 251594dae..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app131/HelloController.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.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; - -@RestController -public class HelloController { - - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app131/Organization.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app131/Organization.java deleted file mode 100644 index eaaa2356f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app131/Organization.java +++ /dev/null @@ -1,45 +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; - -@Schema(description = - "This is the description being overwritten") -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"id", "name"}) -public class Organization { - - @Schema( - description = - "The Universally Unique Identifier (UUID) uniquely identifying the organization", - required = true) - @JsonProperty(required = true) - private UUID id; - - @Schema(description = "The name of the organization", required = true) - @JsonProperty(required = true) - private String name; - - public Organization() {} - - public UUID getId() { - return id; - } - - public String getName() { - return name; - } - - public void setId(UUID id) { - this.id = id; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app131/RestControllerError.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app131/RestControllerError.java deleted file mode 100644 index 4c7828ae0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app131/RestControllerError.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app131; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class RestControllerError { - - @JsonProperty - private String id; - - @JsonProperty - private String message; - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app132/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app132/HelloController.java deleted file mode 100644 index 059e7e259..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app132/HelloController.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.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; - -@RestController -public class HelloController { - - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app132/Organization.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app132/Organization.java deleted file mode 100644 index c18961a86..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app132/Organization.java +++ /dev/null @@ -1,45 +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; - -@Schema(description = - "This is the description being overwritten") -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"id", "name"}) -public class Organization { - - @Schema( - description = - "The Universally Unique Identifier (UUID) uniquely identifying the organization", - required = true) - @JsonProperty(required = true) - private UUID id; - - @Schema(description = "The name of the organization", required = true) - @JsonProperty(required = true) - private String name; - - public Organization() {} - - public UUID getId() { - return id; - } - - public String getName() { - return name; - } - - public void setId(UUID id) { - this.id = id; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app132/RestControllerError.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app132/RestControllerError.java deleted file mode 100644 index a63a8f602..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app132/RestControllerError.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app132; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class RestControllerError { - - @JsonProperty - private String id; - - @JsonProperty - private String message; - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app133/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app133/HelloController.java deleted file mode 100644 index 7032cdfb7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app133/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.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; - -@RestController -public class HelloController { - - @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; - } - - @GetMapping("/test2") - public String getMessageFromHeader2( - @Parameter(name = "myHeader", description = "A header", schema = @Schema(type = "integer")) - @RequestHeader("myHeader") Integer header - ) { - return "bar " + header; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app134/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app134/HelloController.java deleted file mode 100644 index 4a949a2cc..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app134/HelloController.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.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; - - -@SpringBootApplication -@RestController -@Tag(name = "The sample resource") -public class HelloController { - - // ----------------------------------------------------------------------------------------------------------------- - - public static final String VERSION_1 = "application/vnd.samples.v1+json"; - public static final String VERSION_2 = "application/vnd.samples.v2+json"; - public static final String HEADER_1 = "X-API-VERSION=1"; - public static final String HEADER_2 = "Accept-version=v2"; - - @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); - } - - @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); - } - - @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())); - } - - - private class SampleV1 { - - public String getId() { - return id; - } - - public SampleV1(String id) { - this.id = id; - } - - public void setId(String id) { - this.id = id; - } - - private String id; - } - - private class SampleV2 { - private long id; - - public SampleV2(long id) { - this.id = id; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - } - - private class SampleSearchRequest { - private final long id; - - public SampleSearchRequest(long id) { - this.id = id; - } - - public long getId() { - return id; - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app134/OpenApiConfig.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app134/OpenApiConfig.java deleted file mode 100644 index 12aba820d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app134/OpenApiConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -package test.org.springdoc.api.app134; - -import org.springdoc.core.GroupedOpenApi; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class OpenApiConfig { - - @Bean - public GroupedOpenApi groupV1OpenApi() { - return GroupedOpenApi.builder() - .group("v1-group").producesToMatch(HelloController.VERSION_1) - .build(); - } - - @Bean - public GroupedOpenApi groupV2OpenApi() { - return GroupedOpenApi.builder() - .group("v2-group").producesToMatch(HelloController.VERSION_2) - .build(); - } - - @Bean - public GroupedOpenApi groupV3OpenApi() { - return GroupedOpenApi.builder() - .group("v2-consumes-group").consumesToMatch(HelloController.VERSION_2) - .build(); - } - - @Bean - public GroupedOpenApi groupV4OpenApi() { - return GroupedOpenApi.builder() - .group("v1-headers-group").headersToMatch(HelloController.HEADER_1) - .build(); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app135/Book.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app135/Book.java deleted file mode 100644 index ae8713f1e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app135/Book.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.app135; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app135/BookRepository.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app135/BookRepository.java deleted file mode 100644 index 85ed40695..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app135/BookRepository.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.app135; - -import java.util.Arrays; -import java.util.List; - -import org.springframework.stereotype.Component; - -@Component -public class BookRepository { - - List findByAuthor(String author){ - Book[] books = {new Book("1", "title1","author1")}; - return Arrays.asList(books); - } - - List findAll() { - Book[] books = {new Book("2", "title2","author2")}; - return Arrays.asList(books); } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app135/BookRouter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app135/BookRouter.java deleted file mode 100644 index df223a25d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app135/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.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; - -@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 - 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"))))); - } - - @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"))))); - } - - @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"))))); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app136/OperationIdController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app136/OperationIdController.java deleted file mode 100644 index 76f3d2ade..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app136/OperationIdController.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.app136; - -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 String opIdTest() { - return ""; - } - - @GetMapping(path = "/test_1") // gets operationId opIdTest_2 - public String opIdTest(@RequestParam String param) { - return ""; - } - - @GetMapping(path = "/test_2") // gets operationId opIdTest_1 - public String opIdTest(@RequestParam Integer param) { - return ""; - } - - @GetMapping(path = "/test_3") // gets operationId opIdTest - public String opIdTest(@RequestParam Boolean param) { - return ""; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app137/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app137/HelloController.java deleted file mode 100644 index 3ff40aefc..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app137/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.app137; - -import io.swagger.v3.oas.annotations.security.SecurityRequirement; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@SecurityRequirement(name = "security_auth") -public class HelloController { - - @GetMapping("/test") - public void test(String hello) { - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app137/OpenApiConfig.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app137/OpenApiConfig.java deleted file mode 100644 index 7d5681ffe..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app137/OpenApiConfig.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.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; - -@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 = { }))) -public class OpenApiConfig {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app138/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app138/HelloController.java deleted file mode 100644 index 1caccc58a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app138/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.app138; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/testB") - public void testB(String hello) { - } - - @GetMapping("/testA") - public void testA(String hello) { - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app139/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app139/HelloController.java deleted file mode 100644 index d017e0687..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app139/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.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; - -@RestController -public class HelloController { - - @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test1") - public String echo1(@RequestParam(name = "${test.name}", defaultValue = "${test.default-value}") String text) { - return text; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app14/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app14/HelloController.java deleted file mode 100644 index 1e9a617fa..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app14/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.app14; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; - -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.http.HttpEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@Tag(name = "greeting", description = "test") -public class HelloController { - - @GetMapping("/persons") - public void persons(@Valid @NotBlank String name) { - - } - - @GetMapping("/test") - @Tag(name = "lang.change") - public HttpEntity demo2() { - return null; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app14/SpringDocApp14Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app14/SpringDocApp14Test.java deleted file mode 100644 index 49a75735f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app14/SpringDocApp14Test.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.app14; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp14Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app140/HelloApplication.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app140/HelloApplication.java deleted file mode 100644 index 6f300c7b3..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app140/HelloApplication.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 the original author or authors. - * * * * - * * * * Licensed under the Apache License, Version 2.0 (the "License"); - * * * * you may not use this file except in compliance with the License. - * * * * You may obtain a copy of the License at - * * * * - * * * * https://www.apache.org/licenses/LICENSE-2.0 - * * * * - * * * * Unless required by applicable law or agreed to in writing, software - * * * * distributed under the License is distributed on an "AS IS" BASIS, - * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 javax.servlet.FilterChain; -import javax.servlet.GenericFilter; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; - -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.Constants.OPERATION_ATTRIBUTE; -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springframework.web.servlet.function.RouterFunctions.route; -import static org.springframework.web.servlet.function.ServerResponse.ok; - -@Configuration -public class HelloApplication { - - private static ServerResponse filter(ServerRequest serverRequest, HandlerFunction handlerFunction) throws Exception { - return handlerFunction.handle(serverRequest); - } - - @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(); - } -} - -@Component -class SimpleFilter extends GenericFilter { - - @Override - public void doFilter(ServletRequest req, ServletResponse res, - FilterChain filterChain) throws IOException, ServletException { - filterChain.doFilter(req, res); - } -} - -@Component -class PersonHandler { - - private final PersonService personService; - - PersonHandler(PersonService personService) { - this.personService = personService; - } - - ServerResponse handleGetAllPeople(ServerRequest serverRequest) { - return ok().body(personService.all()); - } - - 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); - } - - ServerResponse handleGetPersonById(ServerRequest r) { - return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); - } -} - -@RestController -class GreetingsRestController { - - @GetMapping("/greet/{name}") - String greet(@PathVariable String name) { - return "hello " + name + "!"; - } -} - -@Service -class PersonService { - - private final AtomicLong counter = new AtomicLong(); - - 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)); - - - Person save(Person p) { - Person person = new Person(counter.incrementAndGet(), p.getName()); - this.people.add(person); - return person; - } - - Set all() { - return this.people; - } - - 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!")); - } - -} - -class Person { - - public Person(Long id, String name) { - this.id = id; - this.name = name; - } - - 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; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app141/Book.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app141/Book.java deleted file mode 100644 index be0508a8e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app141/Book.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.app141; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app141/BookRepository.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app141/BookRepository.java deleted file mode 100644 index 0d5e342da..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app141/BookRepository.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.app141; - -import java.util.Arrays; -import java.util.List; - -import org.springframework.stereotype.Component; - -@Component -public class BookRepository { - - List findByAuthor(String author){ - Book[] books = {new Book("1", "title1","author1")}; - return Arrays.asList(books); - } - - List findAll() { - Book[] books = {new Book("2", "title2","author2")}; - return Arrays.asList(books); } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app141/BookRouter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app141/BookRouter.java deleted file mode 100644 index 3a0e78c9c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app141/BookRouter.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 the original author or authors. - * * * * - * * * * Licensed under the Apache License, Version 2.0 (the "License"); - * * * * you may not use this file except in compliance with the License. - * * * * You may obtain a copy of the License at - * * * * - * * * * https://www.apache.org/licenses/LICENSE-2.0 - * * * * - * * * * Unless required by applicable law or agreed to in writing, software - * * * * distributed under the License is distributed on an "AS IS" BASIS, - * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.Constants.OPERATION_ATTRIBUTE; -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -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; - -@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())) - .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"))) - ); - } - - @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")))); - } - - @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")))); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app142/HelloApplication.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app142/HelloApplication.java deleted file mode 100644 index 3fe3ff7e5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app142/HelloApplication.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 the original author or authors. - * * * * - * * * * Licensed under the Apache License, Version 2.0 (the "License"); - * * * * you may not use this file except in compliance with the License. - * * * * You may obtain a copy of the License at - * * * * - * * * * https://www.apache.org/licenses/LICENSE-2.0 - * * * * - * * * * Unless required by applicable law or agreed to in writing, software - * * * * distributed under the License is distributed on an "AS IS" BASIS, - * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 javax.servlet.FilterChain; -import javax.servlet.GenericFilter; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -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.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.springframework.web.servlet.function.ServerResponse.ok; - -@Configuration -public class HelloApplication { - - private static ServerResponse filter(ServerRequest serverRequest, HandlerFunction handlerFunction) throws Exception { - return handlerFunction.handle(serverRequest); - } - - @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(); - } - -} - -@Component -class SimpleFilter extends GenericFilter { - - @Override - public void doFilter(ServletRequest req, ServletResponse res, - FilterChain filterChain) throws IOException, ServletException { - filterChain.doFilter(req, res); - } -} - -@Component -class PersonHandler { - - private final PersonService personService; - - PersonHandler(PersonService personService) { - this.personService = personService; - } - - ServerResponse handleGetAllPeople(ServerRequest serverRequest) { - return ok().body(personService.all()); - } - - 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); - } - - ServerResponse handleGetPersonById(ServerRequest r) { - return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); - } -} - -@RestController -class GreetingsRestController { - - @GetMapping("/greet/{name}") - String greet(@PathVariable String name) { - return "hello " + name + "!"; - } -} - -@Service -class PersonService { - - private final AtomicLong counter = new AtomicLong(); - - 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)); - - - Person save(Person p) { - Person person = new Person(counter.incrementAndGet(), p.getName()); - this.people.add(person); - return person; - } - - Set all() { - return this.people; - } - - 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!")); - } - -} - -class Person { - - public Person(Long id, String name) { - this.id = id; - this.name = name; - } - - 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; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app143/HelloHiddenController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app143/HelloHiddenController.java deleted file mode 100644 index 76c59eb64..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app143/HelloHiddenController.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.app143; - -import io.swagger.v3.oas.annotations.Hidden; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@Hidden -public class HelloHiddenController { - - @GetMapping("/testA") - public void testA(String hello) { - } - - @GetMapping("/testB") - public void testB(String hello) { - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app143/SpringDocApp143Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app143/SpringDocApp143Test.java deleted file mode 100644 index 944790f08..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app143/SpringDocApp143Test.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.app143; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * Test issue 907 fix. - * Hidden controller showing up in swagger UI when springdoc.show-actuator is enabled - */ -@TestPropertySource(properties = {"management.endpoints.enabled-by-default=true", - "springdoc.show-actuator=true", "management.endpoints.web.exposure.exclude=functions" -}) -public class SpringDocApp143Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app144/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app144/HelloController.java deleted file mode 100644 index 59fee7564..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app144/SpringDocApp144Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app144/SpringDocApp144Test.java deleted file mode 100644 index 060a39f81..000000000 --- a/springdoc-openapi-webmvc-core/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.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=55554", - "springdoc.use-management-port=true", - "management.server.port=9090", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp144Test extends AbstractSpringDocActuatorTest { - - @SpringBootApplication - static class SpringDocTestApp {} - - @Test - public void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) - .andExpect(status().isNotFound()); - } - - @Test - public void testApp1() throws Exception { - String result = actuatorRestTemplate.getForObject("/application/openapi", String.class); - String expected = getContent("results/app144.json"); - assertEquals(expected, result, true); - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app145/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app145/HelloController.java deleted file mode 100644 index 12891a39e..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app145/SpringDocApp145Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app145/SpringDocApp145Test.java deleted file mode 100644 index 837edc153..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app145/SpringDocApp145Test.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * - * * Copyright 2019-2022 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.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=55556", - "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=9091", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp145Test extends AbstractSpringDocActuatorTest { - - @SpringBootApplication - static class SpringDocTestApp {} - - @Test - public void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) - .andExpect(status().isNotFound()); - } - - @Test - public 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 - public void testApp2() throws Exception { - String result = actuatorRestTemplate.getForObject("/application/openapi/users", String.class); - String expected = getContent("results/app145.json"); - assertEquals(expected, result, true); - } - - @Test - public void testApp3() throws Exception { - try { - actuatorRestTemplate.getForObject("/application/openapi"+ "/"+Constants.DEFAULT_GROUP_NAME, String.class); - fail(); - } - catch (HttpStatusCodeException ex) { - // TODO: Currently obtain status 500 on MVC... Webflux obtain 404... - if (ex.getStatusCode() == HttpStatus.INTERNAL_SERVER_ERROR) - assertTrue(true); - else - fail(); - } - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app146/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app146/HelloController.java deleted file mode 100644 index 9bacb38df..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app146/SpringDocApp146Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app146/SpringDocApp146Test.java deleted file mode 100644 index e8c5e3e9e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app146/SpringDocApp146Test.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.app146; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.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=9099", - "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 SpringDocApp146Test extends AbstractSpringDocActuatorTest { - - @SpringBootApplication - static class SpringDocTestApp {} - - - @Test - public 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/app146-1.json"), true)); - } - - @Test - public void testApp1() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/"+Constants.DEFAULT_GROUP_NAME)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app146-2.json"), true)); - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app147/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app147/HelloController.java deleted file mode 100644 index c1f7985d7..000000000 --- a/springdoc-openapi-webmvc-core/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.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-webmvc-core/src/test/java/test/org/springdoc/api/app147/SpringDocApp147Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app147/SpringDocApp147Test.java deleted file mode 100644 index 9a574cb27..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app147/SpringDocApp147Test.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * * Copyright 2019-2022 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.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=9097", - "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 { - - @SpringBootApplication - static class SpringDocTestApp {} - - @Test - public 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 - public 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 - public void testApp2() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/"+Constants.DEFAULT_GROUP_NAME)) - .andExpect(status().isNotFound()); - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app148/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app148/HelloController.java deleted file mode 100644 index e2b55cba3..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app148/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.app148; - -import org.springdoc.core.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-webmvc-core/src/test/java/test/org/springdoc/api/app148/SpringDocApp148Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app148/SpringDocApp148Test.java deleted file mode 100644 index af4fdcfdd..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app148/SpringDocApp148Test.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * * Copyright 2019-2022 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.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; -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; - - -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, - properties = { "management.endpoints.web.exposure.include:*", - "springdoc.show-actuator=true", - "management.server.port=9098", - "server.port=6666", - "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 { - - @SpringBootApplication - static class SpringDocTestApp {} - - - @Test - public void testApp() throws Exception { - String result = actuatorRestTemplate.getForObject("/test/application/openapi/users", String.class); - String expected = getContent("results/app148-1.json"); - assertEquals(expected, result, true); - } - - @Test - public void testApp2() throws Exception { - String result = actuatorRestTemplate.getForObject("/test/application/openapi/x-actuator", String.class); - String expected = getContent("results/app148-2.json"); - assertEquals(expected, result, true); - } - - @Test - public void testApp3() throws Exception { - try { - actuatorRestTemplate.getForObject("/test/application/openapi" + "/"+Constants.DEFAULT_GROUP_NAME, String.class); - fail(); - } - catch (HttpStatusCodeException ex) { - // TODO: Currently obtain status 500 on MVC... Webflux obtain 404... - if (ex.getStatusCode() == HttpStatus.INTERNAL_SERVER_ERROR) - assertTrue(true); - else - fail(); - } - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app149/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app149/HelloController.java deleted file mode 100644 index a30d5c2b1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app149/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.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 -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 ModelAndView helloModelAndView() { - ModelAndView mav = new ModelAndView(); - mav.setViewName("forward:/message"); - return mav; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app149/HelloMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app149/HelloMessage.java deleted file mode 100644 index 35868daf0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app149/HelloMessage.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app149/HiddenHelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app149/HiddenHelloController.java deleted file mode 100644 index addf06c49..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app149/SpringDocApp149Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app149/SpringDocApp149Test.java deleted file mode 100644 index 135ea253a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app149/SpringDocApp149Test.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.app149; - -import org.junit.jupiter.api.BeforeAll; -import org.springdoc.core.SpringDocUtils; -import test.org.springdoc.api.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 AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - - @BeforeAll - public static void init() { - SpringDocUtils.getConfig().addHiddenRestControllers(HiddenHelloController.class); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app15/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app15/HelloController.java deleted file mode 100644 index e455a789b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app15/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app15/SpringDocApp15Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app15/SpringDocApp15Test.java deleted file mode 100644 index ec449121b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app15/SpringDocApp15Test.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.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; - -@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" -}) -public class SpringDocApp15Test extends AbstractSpringDocTest { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app150/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app150/HelloController.java deleted file mode 100644 index 3a786c97b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app150/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.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; - -@RestController -public class HelloController { - - @GetMapping("/test/") - @ApiResponse(responseCode = "204", description = "No content") - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void test(@RequestParam(defaultValue = "1") Integer 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) { - - } - - @GetMapping("/test3") - @ApiResponse(responseCode = "204", description = "No content") - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void test3(@RequestParam(defaultValue = "users,123") List toto) { - - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app150/SpringDocApp150Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app150/SpringDocApp150Test.java deleted file mode 100644 index 447232fb8..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app150/SpringDocApp150Test.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.app150; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -public class SpringDocApp150Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app151/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app151/HelloController.java deleted file mode 100644 index f33ab8084..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app151/HelloController.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 org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/test") -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app151/SpringDocApp151Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app151/SpringDocApp151Test.java deleted file mode 100644 index e8c84189d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app151/SpringDocApp151Test.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.app151; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -public class SpringDocApp151Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app152/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app152/HelloController.java deleted file mode 100644 index 3901776a6..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app152/HelloController.java +++ /dev/null @@ -1,30 +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; - -@RestController -@RequestMapping("/api") -public class HelloController { - - @GetMapping - public String helloWorld() { - return "ok"; - } - - @Configuration - public class WebConfig implements WebMvcConfigurer { - - @Override - public void configurePathMatch(PathMatchConfigurer configurer) { - configurer.setPatternParser(new PathPatternParser()); - } - - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app152/SpringDocApp152Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app152/SpringDocApp152Test.java deleted file mode 100644 index a3d99e6e7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app152/SpringDocApp152Test.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.app152; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -public class SpringDocApp152Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app153/OrderState.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app153/OrderState.java deleted file mode 100644 index d6fa549f8..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app153/OrderState.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app153; - -import io.swagger.v3.oas.annotations.media.Schema; - - -@Schema(type="string", allowableValues={"finished", "new"}) -public enum OrderState { - FINISHED("finished"), - NEW("new"); - - OrderState(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - private final String value; -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app153/OrderStateMapper.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app153/OrderStateMapper.java deleted file mode 100644 index b81256716..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app153/OrderStateMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app153; - -import java.beans.PropertyEditorSupport; -import java.util.Arrays; - -import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; - -public class OrderStateMapper extends PropertyEditorSupport { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app153/SpringDocApp153Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app153/SpringDocApp153Test.java deleted file mode 100644 index d19252ff8..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app153/SpringDocApp153Test.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.app153; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -public class SpringDocApp153Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app153/TestController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app153/TestController.java deleted file mode 100644 index 4090efb96..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app153/TestController.java +++ /dev/null @@ -1,22 +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; - -@RestController -class TestController { - - @InitBinder - public void initBinder(WebDataBinder dataBinder) { - dataBinder.registerCustomEditor(OrderState.class, new OrderStateMapper()); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app154/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app154/HelloController.java deleted file mode 100644 index 19d568fcd..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app154/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.app154; - -import java.time.Instant; - -import org.springdoc.api.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; - -@RestController -public class HelloController { - - - @GetMapping(path = "/") - public String hello() { - return "Hello world at " + Instant.now().toString(); - } - - @PostMapping(value = "/persons") - public void create(@ParameterObject Long id, @RequestBody Object o){ - - } - - @PostMapping(value = "/personsone") - public void createone(Long id, @RequestBody Object o){ - - } - - @PostMapping(value = "/createtwo") - public void createtwo(int id){ - - } - - @PostMapping(value = "/createthree") - public void createthree(Integer id){ - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app154/OpenApiConfiguration.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app154/OpenApiConfiguration.java deleted file mode 100644 index e4746a4eb..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app154/OpenApiConfiguration.java +++ /dev/null @@ -1,27 +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; - -@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" - ) -}) -public class OpenApiConfiguration { -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app154/SpringDocApp154Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app154/SpringDocApp154Test.java deleted file mode 100644 index 6334350b0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app154/SpringDocApp154Test.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.app154; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -public class SpringDocApp154Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/AbstractIntParameterObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/AbstractIntParameterObject.java deleted file mode 100644 index db60532a9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/AbstractIntParameterObject.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app155; - -public class AbstractIntParameterObject { - - int primitiveBaseField; - - T genericField; - - public int getPrimitiveBaseField() { - return primitiveBaseField; - } - - public void setPrimitiveBaseField(int primitiveBaseField) { - this.primitiveBaseField = primitiveBaseField; - } - - public T getGenericField() { - return genericField; - } - - public void setGenericField(T genericField) { - this.genericField = genericField; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/AbstractParameterObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/AbstractParameterObject.java deleted file mode 100644 index 80b99fad6..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/AbstractParameterObject.java +++ /dev/null @@ -1,28 +0,0 @@ -package test.org.springdoc.api.app155; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; - -public class AbstractParameterObject> { - - int primitiveBaseField; - - @Parameter(schema=@Schema(type = "string", allowableValues = {"ONE", "TWO"}) ) - T genericField; - - public int getPrimitiveBaseField() { - return primitiveBaseField; - } - - public void setPrimitiveBaseField(int primitiveBaseField) { - this.primitiveBaseField = primitiveBaseField; - } - - public T getGenericField() { - return genericField; - } - - public void setGenericField(T genericField) { - this.genericField = genericField; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/ConcreteEnum.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/ConcreteEnum.java deleted file mode 100644 index 25a18d1bf..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/ConcreteEnum.java +++ /dev/null @@ -1,9 +0,0 @@ -package test.org.springdoc.api.app155; - - - -enum ConcreteEnum { - ONE, - TWO - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/ConcreteIntParameterObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/ConcreteIntParameterObject.java deleted file mode 100644 index 1005d9e40..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/ConcreteIntParameterObject.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app155; - -public class ConcreteIntParameterObject extends AbstractIntParameterObject{ - - int primitiveConcreteField; - - public int getPrimitiveConcreteField() { - return primitiveConcreteField; - } - - public void setPrimitiveConcreteField(int primitiveConcreteField) { - this.primitiveConcreteField = primitiveConcreteField; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/ConcreteParameterObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/ConcreteParameterObject.java deleted file mode 100644 index 93cfe32d6..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/ConcreteParameterObject.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app155; - -public class ConcreteParameterObject extends AbstractParameterObject { - - int primitiveConcreteField; - - public int getPrimitiveConcreteField() { - return primitiveConcreteField; - } - - public void setPrimitiveConcreteField(int primitiveConcreteField) { - this.primitiveConcreteField = primitiveConcreteField; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/HelloController.java deleted file mode 100644 index b71e346c2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/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.app155; - -import org.springdoc.api.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 -public class HelloController { - - @GetMapping( "/test1") - public ResponseEntity sayHello( @ParameterObject final ConcreteParameterObject test) { - System.out.println("Field B = " + test); - return new ResponseEntity("{\"Say\": \"Hello\"}", HttpStatus.OK); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app155/SpringDocApp155Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/SpringDocApp155Test.java deleted file mode 100644 index 9b72b5c65..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app155/SpringDocApp155Test.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.app155; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -public class SpringDocApp155Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app156/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app156/HelloController.java deleted file mode 100644 index f45b3640e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app156/HelloController.java +++ /dev/null @@ -1,45 +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; - -@RestController -public class HelloController { - @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-webmvc-core/src/test/java/test/org/springdoc/api/app156/SomeEnum.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app156/SomeEnum.java deleted file mode 100644 index d35f04b09..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app156/SomeEnum.java +++ /dev/null @@ -1,6 +0,0 @@ -package test.org.springdoc.api.app156; - -public enum SomeEnum { - FIRST, - SECOND -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app156/SpringDocApp156Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app156/SpringDocApp156Test.java deleted file mode 100644 index f07cede85..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app156/SpringDocApp156Test.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.app156; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -public class SpringDocApp156Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app156/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app156/User.java deleted file mode 100644 index 93699c932..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app156/User.java +++ /dev/null @@ -1,33 +0,0 @@ -package test.org.springdoc.api.app156; - -import java.util.Set; - -public class User { - private String someText; - private Set textSet; - private Set someEnums; - - public String getSomeText() { - return someText; - } - - public void setSomeText(String someText) { - this.someText = someText; - } - - public Set getTextSet() { - return textSet; - } - - public void setTextSet(Set textSet) { - this.textSet = textSet; - } - - public Set getSomeEnums() { - return someEnums; - } - - public void setSomeEnums(Set someEnums) { - this.someEnums = someEnums; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/Bar.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/Bar.java deleted file mode 100644 index 8c9ea08d4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/Bar.java +++ /dev/null @@ -1,12 +0,0 @@ -package test.org.springdoc.api.app157; - -/** - * A class without a String in it - */ -public class Bar { - private Object child; - - public Object getChild() { - return this.child; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/Foo.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/Foo.java deleted file mode 100644 index c139567b2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/Foo.java +++ /dev/null @@ -1,12 +0,0 @@ -package test.org.springdoc.api.app157; - -/** - * A class with a String in it - */ -public class Foo { - private String child; - - public String getChild() { - return this.child; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/HelloController.java deleted file mode 100644 index 10a514ba1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/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.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 -public class HelloController { - - @GetMapping( "/foo") - public ResponseEntity getFoo() { - return new ResponseEntity(HttpStatus.OK); - } - - @GetMapping( "/bar") - public ResponseEntity getBar() { - return new ResponseEntity(HttpStatus.OK); - } - - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/SpringDocApp157Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/SpringDocApp157Test.java deleted file mode 100644 index bb2571f12..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/SpringDocApp157Test.java +++ /dev/null @@ -1,55 +0,0 @@ -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.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springdoc.core.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -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. - */ -public class SpringDocApp157Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringBootApp {} - - private StringyConverter myConverter = new StringyConverter(); - - private ModelConverters converters = ModelConverters.getInstance(); - - @BeforeEach - public void registerConverter() { - converters.addConverter(myConverter); - } - - @AfterEach - public void unregisterConverter() { - converters.removeConverter(myConverter); - } - - @Test - public 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")))); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/StringyConverter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/StringyConverter.java deleted file mode 100644 index f2717ad09..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/StringyConverter.java +++ /dev/null @@ -1,25 +0,0 @@ -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.core.util.Json; -import io.swagger.v3.oas.models.media.Schema; - -public class StringyConverter implements ModelConverter { - - @Override - public Schema resolve(AnnotatedType type, ModelConverterContext context, - Iterator chain) { - - JavaType javaType = Json.mapper().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-webmvc-core/src/test/java/test/org/springdoc/api/app158/CommonFooErrorHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/CommonFooErrorHandler.java deleted file mode 100644 index b0593a696..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/CommonFooErrorHandler.java +++ /dev/null @@ -1,14 +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; - -public class CommonFooErrorHandler { - - @ExceptionHandler - @ResponseStatus(HttpStatus.CONFLICT) - public ErrorDTO onException(Exception e) { - return new ErrorDTO("Something wrong has happened"); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/ErrorDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/ErrorDTO.java deleted file mode 100644 index 7768cd658..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/ErrorDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app158; - -public class ErrorDTO { - private String message; - - public ErrorDTO() { - } - - public ErrorDTO(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/HelloController.java deleted file mode 100644 index 99ff55c14..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/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.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; - -@RestController -@RequestMapping("/api") -@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) -public class HelloController { - - @GetMapping("/foo") - public SimpleDTO hello() { - return new SimpleDTO("foo"); - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/SimpleDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/SimpleDTO.java deleted file mode 100644 index b3937de4d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/SimpleDTO.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app158; - -public class SimpleDTO { - - private String payload; - - public SimpleDTO() { - } - - public SimpleDTO(String payload) { - this.payload = payload; - } - - public String getPayload() { - return payload; - } - - public void setPayload(String payload) { - this.payload = payload; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/SpecificFooErrorHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/SpecificFooErrorHandler.java deleted file mode 100644 index ecff65cbe..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/SpecificFooErrorHandler.java +++ /dev/null @@ -1,7 +0,0 @@ -package test.org.springdoc.api.app158; - -import org.springframework.web.bind.annotation.ControllerAdvice; - -@ControllerAdvice(assignableTypes = HelloController.class) -public class SpecificFooErrorHandler extends CommonFooErrorHandler { -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/SpringDocApp158Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/SpringDocApp158Test.java deleted file mode 100644 index af260e6c4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app158/SpringDocApp158Test.java +++ /dev/null @@ -1,12 +0,0 @@ -package test.org.springdoc.api.app158; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp158Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/CustomException.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/CustomException.java deleted file mode 100644 index 1354597e2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/CustomException.java +++ /dev/null @@ -1,7 +0,0 @@ -package test.org.springdoc.api.app159; - -public class CustomException extends RuntimeException{ - public CustomException(String message) { - super(message); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/FooBean.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/FooBean.java deleted file mode 100644 index 0460e74d3..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/FooBean.java +++ /dev/null @@ -1,31 +0,0 @@ -package test.org.springdoc.api.app159; - -import com.fasterxml.jackson.annotation.JsonView; - -public class FooBean { - @JsonView(Views.View2.class) - private String message; - @JsonView(Views.View1.class) - private int code; - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public FooBean(String message, int code) { - this.message = message; - this.code = code; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/FooErrorHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/FooErrorHandler.java deleted file mode 100644 index 6b39b9baf..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/FooErrorHandler.java +++ /dev/null @@ -1,27 +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; - -@ControllerAdvice(assignableTypes = HelloController.class) -public class FooErrorHandler { - - @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); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app159/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/HelloController.java deleted file mode 100644 index 99d53a7bc..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/HelloController.java +++ /dev/null @@ -1,22 +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; - -@RestController -@RequestMapping("/api") -@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) -public class HelloController { - - @PostMapping("/foo") - public String create(@RequestBody String foo) { - return "foo"; - } -} - diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/SpringDocApp159Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/SpringDocApp159Test.java deleted file mode 100644 index 1cdb16b13..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/SpringDocApp159Test.java +++ /dev/null @@ -1,12 +0,0 @@ -package test.org.springdoc.api.app159; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp159Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/Views.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/Views.java deleted file mode 100644 index 78e778372..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app159/Views.java +++ /dev/null @@ -1,8 +0,0 @@ -package test.org.springdoc.api.app159; - -public class Views { - public static class View1 { - } - public static class View2 extends View1 { - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app16/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app16/HelloController.java deleted file mode 100644 index ca142af67..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app16/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.app16; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app16/SpringDocApp16Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app16/SpringDocApp16Test.java deleted file mode 100644 index 8a8f4be6a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app16/SpringDocApp16Test.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.app16; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.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; - -@TestPropertySource(properties = "springdoc.api-docs.enabled=false") -public class SpringDocApp16Test extends AbstractSpringDocTest { - - @Test - public void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) - .andExpect(status().isNotFound()); - } - - @SpringBootConfiguration - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app160/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app160/HelloController.java deleted file mode 100644 index 1555fa75f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app160/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.app160; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import org.springdoc.core.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; - -@RestController -public class HelloController { - - @PostMapping("test") - public ErrorResponse doSomethingInteresting() { - return null; - } - - @PropertySource("classpath:swagger-message-160.properties" ) - @Configuration - public class SwaggerMessage{} - - @Schema(description = "${ErrorResponse}") - public class ErrorResponse { - - @Schema(description = "${ErrorCode}", required = true) - @JsonProperty - private Integer errorCode; - - @Schema(description = "${ErrorMessage}") - @JsonProperty - private String errorMessage; - } - - @Bean - public GroupedOpenApi bundleApi() { - return GroupedOpenApi.builder() - .group("test") - .pathsToMatch("/**") - .build(); - } - - @Bean - public ResourceBundleMessageSource translator() { - ResourceBundleMessageSource source = new ResourceBundleMessageSource(); - source.setBasenames("swagger-message-160"); - source.setUseCodeAsDefaultMessage(true); - source.setDefaultEncoding("utf-8"); - return source; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app160/SpringDocApp160Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app160/SpringDocApp160Test.java deleted file mode 100644 index f50e4e00f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app160/SpringDocApp160Test.java +++ /dev/null @@ -1,31 +0,0 @@ -package test.org.springdoc.api.app160; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.Constants; -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.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@TestPropertySource(properties = "springdoc.api-docs.resolve-schema-properties=true") -public class SpringDocApp160Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - } - - - @Test - public void testApp2() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/test")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app160-1.json"), true)); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app161/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app161/HelloController.java deleted file mode 100644 index 98bc5083f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app161/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.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; - -@RestController -public class HelloController { - - - @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; - } - - - @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; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app161/SpringDocApp161Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app161/SpringDocApp161Test.java deleted file mode 100644 index 3f29e6ea2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app161/SpringDocApp161Test.java +++ /dev/null @@ -1,21 +0,0 @@ -package test.org.springdoc.api.app161; - -import java.util.Locale; - -import org.junit.jupiter.api.Test; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp161Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - - @Test - public void testApp() throws Exception { - Locale.setDefault(Locale.US); - super.testApp(); - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app162/OpenApiConfig.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app162/OpenApiConfig.java deleted file mode 100644 index 85bd53efc..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app162/OpenApiConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app162; - -import java.util.ArrayList; -import java.util.List; - -import io.swagger.v3.oas.models.servers.Server; -import org.springdoc.core.customizers.OpenApiCustomiser; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class OpenApiConfig { - @Bean - OpenApiCustomiser openApiCustomiser() { - return openApi -> { - openApi.getInfo().version("v1"); - Server server = new Server().url(""); - List servers=new ArrayList<>(); - servers.add(server); - openApi.servers(servers); - }; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app162/SpringDocApp162Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app162/SpringDocApp162Test.java deleted file mode 100644 index 9fd72a9f6..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app162/SpringDocApp162Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app162; - -import org.junit.jupiter.api.Test; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp162Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - - @Test - public void testApp2() throws Exception { - super.testApp(); - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/CommissionDto.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/CommissionDto.java deleted file mode 100644 index 0e4fa9feb..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/CommissionDto.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.app163; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class CommissionDto { - private String email; - - private String firstName; - - private String lastName; - - public CommissionDto() { - } - - public CommissionDto(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-webmvc-core/src/test/java/test/org/springdoc/api/app163/CommissionsResource.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/CommissionsResource.java deleted file mode 100644 index 73f8495f6..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/CommissionsResource.java +++ /dev/null @@ -1,53 +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.app163; - -import javax.validation.Valid; - -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.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.PathVariable; -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.MediaType.APPLICATION_JSON_VALUE; -import static org.springframework.http.ResponseEntity.accepted; -import static test.org.springdoc.api.app163.Examples.PUT_COMMISSION_REQUEST_BODY_EXAMPLE_KEY; -import static test.org.springdoc.api.app163.Examples.PUT_COMMISSION_RESPONSE_BODY_EXAMPLE_KEY; - -@RestController -public class CommissionsResource { - - @PutMapping(value = "{id}", consumes = APPLICATION_JSON_VALUE) - @Operation(description = "updateCommission", summary = "Update a commission") - @ApiResponse(responseCode = "202", description = "Commission updated", content = @Content(schema = @Schema(implementation = CommissionDto.class), examples = @ExampleObject(name = "202", ref = PUT_COMMISSION_RESPONSE_BODY_EXAMPLE_KEY))) - public ResponseEntity updateCommission( - @Parameter(description = "Commission's id", required = true) @PathVariable("id") String commissionId, - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "A commission to update", required = true, content = @Content(schema = @Schema(implementation = CommissionDto.class), examples = @ExampleObject(name="requestExample", ref = PUT_COMMISSION_REQUEST_BODY_EXAMPLE_KEY))) @RequestBody(required = true) @Valid CommissionDto commission) { - return accepted().body(commission); - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/ExampleRegistrationCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/ExampleRegistrationCustomizer.java deleted file mode 100644 index 8aaec28e1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/ExampleRegistrationCustomizer.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.org.springdoc.api.app163; - -import java.util.List; -import java.util.Map; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.examples.Example; -import org.springdoc.core.customizers.OpenApiCustomiser; - -import org.springframework.stereotype.Component; - -@Component -public class ExampleRegistrationCustomizer implements OpenApiCustomiser { - - private final List> examplesToRegister; - - public ExampleRegistrationCustomizer(List> examplesToRegister) { - this.examplesToRegister = examplesToRegister; - } - - @Override - public void customise(OpenAPI openApi) { - examplesToRegister.forEach(entry -> openApi.getComponents().addExamples(entry.getKey(), entry.getValue())); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/SpringDocApp163Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/SpringDocApp163Test.java deleted file mode 100644 index 96fb87ed5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/SpringDocApp163Test.java +++ /dev/null @@ -1,34 +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.app163; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Import; - -public class SpringDocApp163Test extends AbstractSpringDocTest { - - @SpringBootApplication - @Import({ Examples.class, ExampleRegistrationCustomizer.class }) - static class SpringDocTestApp { - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app164/SampleResponseClass.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app164/SampleResponseClass.java deleted file mode 100644 index 988b850b0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app164/SampleResponseClass.java +++ /dev/null @@ -1,45 +0,0 @@ -package test.org.springdoc.api.app164; - -public class SampleResponseClass { - - private String idAsFirstParameter; - - private String nameAsSecondParamater; - - private String lastNameAsThirdParameter; - - private boolean booleanValueAsFourthParameter; - - public String getIdAsFirstParameter() { - return idAsFirstParameter; - } - - public void setIdAsFirstParameter(String idAsFirstParameter) { - this.idAsFirstParameter = idAsFirstParameter; - } - - public String getNameAsSecondParamater() { - return nameAsSecondParamater; - } - - public void setNameAsSecondParamater(String nameAsSecondParamater) { - this.nameAsSecondParamater = nameAsSecondParamater; - } - - public String getLastNameAsThirdParameter() { - return lastNameAsThirdParameter; - } - - public void setLastNameAsThirdParameter(String lastNameAsThirdParameter) { - this.lastNameAsThirdParameter = lastNameAsThirdParameter; - } - - public boolean isBooleanValueAsFourthParameter() { - return booleanValueAsFourthParameter; - } - - public void setBooleanValueAsFourthParameter(boolean aBooleanValueAsFourthParameter) { - this.booleanValueAsFourthParameter = aBooleanValueAsFourthParameter; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app164/SpringDocApp164Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app164/SpringDocApp164Test.java deleted file mode 100644 index 6283b21d9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app164/SpringDocApp164Test.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.app164; - -import test.org.springdoc.api.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 AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app164/TestApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app164/TestApiController.java deleted file mode 100644 index 1674e67bf..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app164/TestApiController.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app164; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class TestApiController { - - @GetMapping(value = "/test") - public SampleResponseClass getInvoices() { - return null; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app165/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app165/HelloController.java deleted file mode 100644 index 9ce34bada..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app165/HelloController.java +++ /dev/null @@ -1,38 +0,0 @@ -package test.org.springdoc.api.app165; - -import java.util.List; - -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.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author bnasslahsen - */ -@RestController -@RequestMapping("/api") -public class HelloController { - - @Operation(description = "I want here some custom config") - @GetMapping("/sample1/{springdoc}") - public ResponseEntity sample1(@PathVariable(name = "#{T(org.springdoc.core.Constants).SPRINGDOC_PREFIX}") String id) { - throw new UnsupportedOperationException("the body is not relevant now"); - } - - @Operation(description = "I want here another some custom config") - @GetMapping("/sample2") - public ResponseEntity sample2(@RequestParam(defaultValue = "#{{}}") List value) { - throw new UnsupportedOperationException("the body is not relevant now"); - } - - @Operation(description = "I want here another some custom config") - @GetMapping("/sample3") - public ResponseEntity sample3(@RequestParam(defaultValue = "#{T(org.springdoc.core.Constants).DEFAULT_SWAGGER_UI_PATH}") String id) { - throw new UnsupportedOperationException("the body is not relevant now"); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app165/SpringDocApp165Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app165/SpringDocApp165Test.java deleted file mode 100644 index 5187ed8d8..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app165/SpringDocApp165Test.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app165; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp165Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/GlobalErrorResponseDto.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/GlobalErrorResponseDto.java deleted file mode 100644 index 637358763..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/GlobalErrorResponseDto.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app166; - -public class GlobalErrorResponseDto { - - private String globalMessage; - - public GlobalErrorResponseDto(String globalMessage) { - this.globalMessage = globalMessage; - } - - public String getGlobalMessage() { - return globalMessage; - } - - public void setGlobalMessage(String globalMessage) { - this.globalMessage = globalMessage; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/GlobalExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/GlobalExceptionHandler.java deleted file mode 100644 index 7cebb142a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/GlobalExceptionHandler.java +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app166; - -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -@RestControllerAdvice -@Component("1") // bean name override to simulate order in HashMap -public class GlobalExceptionHandler { - - @ExceptionHandler(RuntimeException.class) - @ResponseStatus - public GlobalErrorResponseDto processException() { - return new GlobalErrorResponseDto("global"); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/LocalErrorResponseDto.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/LocalErrorResponseDto.java deleted file mode 100644 index 45f9adb52..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/LocalErrorResponseDto.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app166; - -public class LocalErrorResponseDto { - - private String localMessage; - - public LocalErrorResponseDto(String localMessage) { - this.localMessage = localMessage; - } - - public String getLocalMessage() { - return localMessage; - } - - public void setLocalMessage(String localMessage) { - this.localMessage = localMessage; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/SpringDocApp166Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/SpringDocApp166Test.java deleted file mode 100644 index 3c2b3045e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/SpringDocApp166Test.java +++ /dev/null @@ -1,37 +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.app166; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * In this test, it is checked that the error handler is displayed correctly in the documentation. - * Exactly, that the local handler takes precedence over the global one - * */ -@TestPropertySource(properties = "springdoc.api-docs.resolve-schema-properties=true") -public class SpringDocApp166Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/TestApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/TestApiController.java deleted file mode 100644 index fcfa0e2a9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app166/TestApiController.java +++ /dev/null @@ -1,23 +0,0 @@ -package test.org.springdoc.api.app166; - -import org.springframework.stereotype.Component; -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 -@Component("0") // bean name override to simulate order in HashMap -public class TestApiController { - - @GetMapping(value = "/test") - public String throwError() { - throw new IllegalArgumentException(); - } - - @ExceptionHandler(RuntimeException.class) - @ResponseStatus - public LocalErrorResponseDto processException() { - return new LocalErrorResponseDto("local"); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app167/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app167/HelloController.java deleted file mode 100644 index f531733e5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app167/HelloController.java +++ /dev/null @@ -1,23 +0,0 @@ -package test.org.springdoc.api.app167; - -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.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author bnasslahsen - */ -@RestController -@RequestMapping("/api") -public class HelloController { - - @GetMapping("/sample1") - public ResponseEntity sample1(@Parameter(name="mySample") String mySample) { - throw new UnsupportedOperationException("the body is not relevant now"); - } - - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app167/SpringDocApp167Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app167/SpringDocApp167Test.java deleted file mode 100644 index b4cc34fe9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app167/SpringDocApp167Test.java +++ /dev/null @@ -1,34 +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.app167; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - - -@TestPropertySource(properties = "springdoc.disable-i18n=true") -public class SpringDocApp167Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app168/AbstractParent.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app168/AbstractParent.java deleted file mode 100644 index fde031f7d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app168/AbstractParent.java +++ /dev/null @@ -1,47 +0,0 @@ -package test.org.springdoc.api.app168; - -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; - -@JsonTypeInfo(use = Id.NAME, property = "type") -@JsonSubTypes({ - @Type(ChildOfAbstract1.class), - @Type(ChildOfAbstract2.class) -}) -public abstract class AbstractParent { - private int id; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } -} - -class ChildOfAbstract1 extends AbstractParent { - private String abstrachChild1Param; - - public String getAbstrachChild1Param() { - return abstrachChild1Param; - } - - public void setAbstrachChild1Param(String abstrachChild1Param) { - this.abstrachChild1Param = abstrachChild1Param; - } -} - -class ChildOfAbstract2 extends AbstractParent { - private String abstractChild2Param; - - public String getAbstractChild2Param() { - return abstractChild2Param; - } - - public void setAbstractChild2Param(String abstractChild2Param) { - this.abstractChild2Param = abstractChild2Param; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app168/ConcreteParent.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app168/ConcreteParent.java deleted file mode 100644 index cae8e083a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app168/ConcreteParent.java +++ /dev/null @@ -1,47 +0,0 @@ -package test.org.springdoc.api.app168; - -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; - -@JsonTypeInfo(use = Id.NAME, property = "type") -@JsonSubTypes({ - @Type(ChildOfConcrete1.class), - @Type(ChildOfConcrete2.class) -}) -public class ConcreteParent { - private int id; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } -} - -class ChildOfConcrete1 extends ConcreteParent { - private String concreteChild1Param; - - public String getConcreteChild1Param() { - return concreteChild1Param; - } - - public void setConcreteChild1Param(String concreteChild1Param) { - this.concreteChild1Param = concreteChild1Param; - } -} - -class ChildOfConcrete2 extends ConcreteParent { - private String concreteChild2Param; - - public String getConcreteChild2Param() { - return concreteChild2Param; - } - - public void setConcreteChild2Param(String concreteChild2Param) { - this.concreteChild2Param = concreteChild2Param; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app168/Controller.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app168/Controller.java deleted file mode 100644 index c3a39fc6f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app168/Controller.java +++ /dev/null @@ -1,44 +0,0 @@ -package test.org.springdoc.api.app168; - -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; - -@RestController -@RequestMapping("class-hierarchy") -public class Controller { - @PostMapping("abstract-parent") - public Response abstractParent(@RequestBody AbstractParent payload) { - return null; - } - - @PostMapping("concrete-parent") - public Response concreteParent(@RequestBody ConcreteParent payload) { - return null; - } -} - -class Response { - AbstractParent abstractParent; - - List concreteParents; - - public AbstractParent getAbstractParent() { - return abstractParent; - } - - public void setAbstractParent(AbstractParent abstractParent) { - this.abstractParent = abstractParent; - } - - public List getConcreteParents() { - return concreteParents; - } - - public void setConcreteParents(List concreteParents) { - this.concreteParents = concreteParents; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app168/SpringDocApp168Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app168/SpringDocApp168Test.java deleted file mode 100644 index a7e1e9cea..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app168/SpringDocApp168Test.java +++ /dev/null @@ -1,28 +0,0 @@ -package test.org.springdoc.api.app168; - -import java.util.Optional; - -import io.swagger.v3.core.converter.ModelConverter; -import io.swagger.v3.core.converter.ModelConverters; -import org.springdoc.core.Constants; -import org.springdoc.core.converters.PolymorphicModelConverter; -import test.org.springdoc.api.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 AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - - static { - Optional modelConverterOptional = - ModelConverters.getInstance().getConverters() - .stream().filter(modelConverter -> modelConverter instanceof PolymorphicModelConverter).findAny(); - modelConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app169/DefaultRequestMappingHandlerMapping.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app169/DefaultRequestMappingHandlerMapping.java deleted file mode 100644 index 39944eeae..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app169/DefaultRequestMappingHandlerMapping.java +++ /dev/null @@ -1,42 +0,0 @@ -package test.org.springdoc.api.app169; - -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.servlet.mvc.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-webmvc-core/src/test/java/test/org/springdoc/api/app169/DefaultWebMvcRegistrations.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app169/DefaultWebMvcRegistrations.java deleted file mode 100644 index 137371783..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app169/DefaultWebMvcRegistrations.java +++ /dev/null @@ -1,15 +0,0 @@ -package test.org.springdoc.api.app169; - -import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations; -import org.springframework.stereotype.Component; -import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; - -@Component -public class DefaultWebMvcRegistrations implements WebMvcRegistrations { - - @Override - public RequestMappingHandlerMapping getRequestMappingHandlerMapping() { - return new DefaultRequestMappingHandlerMapping(); - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app169/SpringDocApp169Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app169/SpringDocApp169Test.java deleted file mode 100644 index ff0c28990..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app169/SpringDocApp169Test.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app169; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -public class SpringDocApp169Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app169/TestController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app169/TestController.java deleted file mode 100644 index 54fdaacac..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app169/TestController.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app169; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app17/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app17/HelloController.java deleted file mode 100644 index 4ce1d114a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app17/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.app17; - -import javax.validation.Valid; -import javax.validation.constraints.Size; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/persons") - public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) { - - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app17/SpringDocApp17Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app17/SpringDocApp17Test.java deleted file mode 100644 index 982f4ec82..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app17/SpringDocApp17Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app170/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app170/HelloController.java deleted file mode 100644 index 73a874a1e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app170/HelloController.java +++ /dev/null @@ -1,12 +0,0 @@ -package test.org.springdoc.api.app170; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - @GetMapping("hello") - public String hello() { - return "Hello"; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app170/SpringDocApp170Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app170/SpringDocApp170Test.java deleted file mode 100644 index 0b9b19584..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app170/SpringDocApp170Test.java +++ /dev/null @@ -1,26 +0,0 @@ -package test.org.springdoc.api.app170; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.customizers.OpenApiCustomiser; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - - -public class SpringDocApp170Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - @Bean - public OpenApiCustomiser openApiCustomiser() { - return openApi -> openApi.getServers().forEach(s -> s.url("URL")); - } - } - - @Test - public void testApp1() throws Exception { - this.testApp(); - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app171/HelloLocaleController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app171/HelloLocaleController.java deleted file mode 100644 index 5d8be0a91..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app171/HelloLocaleController.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.app171; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; - -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.http.HttpEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@Tag(name = "greeting", description = "test") -public class HelloLocaleController { - - @GetMapping("/persons") - public void persons(@Valid @NotBlank String name) { - } - - @GetMapping("/test") - public HttpEntity demo2() { - return null; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app171/SpringDocApp171Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app171/SpringDocApp171Test.java deleted file mode 100644 index 7df6629e5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app171/SpringDocApp171Test.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.app171; - -import java.util.Locale; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.Constants; -import org.springdoc.core.customizers.OpenApiLocaleCustomizer; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.support.ResourceBundleMessageSource; -import org.springframework.http.HttpHeaders; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.web.servlet.MvcResult; - -import static org.hamcrest.Matchers.is; -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@TestPropertySource(properties = Constants.SPRINGDOC_CACHE_DISABLED + "=false") -public class SpringDocApp171Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - - @Autowired - ResourceBundleMessageSource resourceBundleMessageSource; - - @Bean - public OpenApiLocaleCustomizer openApiLocaleCustomizer() { - return (openAPI, locale) - -> openAPI.getInfo().title(resourceBundleMessageSource.getMessage("test", null, locale)); - } - - } - - @Test - @Override - public void testApp() throws Exception { - Locale.setDefault(Locale.US); - testApp(Locale.US); - testApp(Locale.FRANCE); - testApp(Locale.UK); - } - - private void testApp(Locale locale) throws Exception { - className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL).locale(locale).header(HttpHeaders.ACCEPT_LANGUAGE, locale.toLanguageTag())).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - String result = mockMvcResult.getResponse().getContentAsString(); - String expected = getContent("results/app" + testNumber + "-" + locale.toLanguageTag() + ".json"); - assertEquals(expected, result, true); - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app172/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app172/HelloController.java deleted file mode 100644 index 818ab459b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app172/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.app172; - - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -@RestController -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-webmvc-core/src/test/java/test/org/springdoc/api/app172/SpringDocApp172Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app172/SpringDocApp172Test.java deleted file mode 100644 index 7b68f90ac..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app172/SpringDocApp172Test.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.app172; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.Constants; -import org.springdoc.core.GroupedOpenApi; -import org.springdoc.core.customizers.OpenApiCustomiser; -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.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; - -@TestPropertySource(properties = { "springdoc.show-actuator=true", "management.endpoints.enabled-by-default=true", - "management.endpoints.web.exposure.include = tenant" }) -public class SpringDocApp172Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - @Bean - public GroupedOpenApi actuatorApi(OpenApiCustomiser actuatorOpenApiCustomiser, OperationCustomizer actuatorCustomizer) { - return GroupedOpenApi.builder() - .group("sample-group") - .packagesToScan("test.org.springdoc.api.app172") - .addOpenApiCustomiser(actuatorOpenApiCustomiser) - .addOperationCustomizer(actuatorCustomizer) - .pathsToExclude("/health/*") - .build(); - } - } - - @Test - public void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/sample-group")) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(status().isOk()) - .andExpect(content().json(getContent("results/app172.json"), true)); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app173/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app173/HelloController.java deleted file mode 100644 index ac0ee2eea..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app173/HelloController.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app173; - -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"); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app173/SpringDocApp173Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app173/SpringDocApp173Test.java deleted file mode 100644 index be267924f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app173/SpringDocApp173Test.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.app173; - -import java.util.Locale; - -import io.swagger.v3.oas.models.OpenAPI; -import org.junit.jupiter.api.Test; -import org.springdoc.core.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.http.HttpHeaders; -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; - -public class SpringDocApp173Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - @Bean - public OpenAPI openAPI() { - return new OpenAPI(); - } - } - - @Test - @Override - public void testApp() throws Exception { - Locale.setDefault(Locale.US); - testApp(Locale.US); - testApp(Locale.FRANCE); - } - - private void testApp(Locale locale) throws Exception { - className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL).locale(locale).header(HttpHeaders.ACCEPT_LANGUAGE, locale.toLanguageTag())).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - String result = mockMvcResult.getResponse().getContentAsString(); - String expected = getContent("results/app" + testNumber +".json"); - assertEquals(expected, result, true); - } - - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app174/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app174/PersonDTO.java deleted file mode 100644 index 2ba7bc4fb..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app174/SpringDocApp174Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app174/SpringDocApp174Test.java deleted file mode 100644 index 391e54b6a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app174/SpringDocApp174Test.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.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 java.util.stream.Collectors; - -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.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.Import; -import org.springframework.web.bind.annotation.RequestMethod; - -@Import({ ReactorAutoConfiguration.class, FunctionExporterAutoConfiguration.class, ContextFunctionCatalogAutoConfiguration.class }) -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).collect(Collectors.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 = test.org.springdoc.api.app175.PersonDTO.class))))) - public Supplier helloSupplier() { - return test.org.springdoc.api.app175.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-webmvc-core/src/test/java/test/org/springdoc/api/app175/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app175/PersonDTO.java deleted file mode 100644 index ee4ed2488..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app176/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app176/HelloController.java deleted file mode 100644 index 1dc9b2e54..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app176/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.app176; - -import java.util.List; - -import org.springdoc.api.annotations.ParameterObject; -import test.org.springdoc.api.app13.PersonDTO; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app176/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app176/PersonDTO.java deleted file mode 100644 index 6950a1d87..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app176/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.app176; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app177/AnnotatedController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app177/AnnotatedController.java deleted file mode 100644 index 993ffd91c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app177/AnnotatedController.java +++ /dev/null @@ -1,80 +0,0 @@ -package test.org.springdoc.api.app177; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -import org.springdoc.core.GroupedOpenApi; -import org.springdoc.core.filters.OpenApiMethodFilter; - -import org.springframework.context.annotation.Bean; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class AnnotatedController { - - @Group1 - @GetMapping("/annotated") - public String annotatedGet() { - return "annotated"; - } - - @Group1 - @Group3 - @PostMapping("/annotated") - public String annotatedPost() { - return "annotated"; - } - - @Group2 - @Group3 - @PutMapping("/annotated") - public String annotatedPut() { - return "annotated"; - } - - @PostMapping("/notAnnotated") - public String notAnnotatedPost() { - return "annotated"; - } - - @Bean - public GroupedOpenApi group1OpenApi() { - return GroupedOpenApi.builder() - .group("annotatedGroup1") - .addOpenApiMethodFilter(method -> method.isAnnotationPresent(Group1.class)) - .build(); - } - - @Bean - public GroupedOpenApi group2OpenApi() { - return GroupedOpenApi.builder() - .group("annotatedGroup2") - .addOpenApiMethodFilter(method -> method.isAnnotationPresent(Group2.class)) - .build(); - } - - @Bean - public GroupedOpenApi group3OpenApi() { - return GroupedOpenApi.builder() - .group("annotatedCombinedGroup") - .addOpenApiMethodFilter(method -> method.isAnnotationPresent(Group1.class) || method.isAnnotationPresent(Group2.class)) - .build(); - } - - @Bean - public OpenApiMethodFilter methodFilter(){ - return method -> method.isAnnotationPresent(Group3.class); - } - - @Retention(RetentionPolicy.RUNTIME) - @interface Group1 {} - - @Retention(RetentionPolicy.RUNTIME) - @interface Group2 {} - - @Retention(RetentionPolicy.RUNTIME) - @interface Group3 {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app178/AnnotatedController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app178/AnnotatedController.java deleted file mode 100644 index da4e33b94..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app178/AnnotatedController.java +++ /dev/null @@ -1,79 +0,0 @@ -package test.org.springdoc.api.app178; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.reflect.Method; -import java.util.function.Predicate; - -import org.springdoc.core.GroupedOpenApi; -import org.springdoc.core.customizers.OperationCustomizer; - -import org.springframework.context.annotation.Bean; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class AnnotatedController { - - @Group1 - @GetMapping("/annotated") - public String annotatedGet() { - return "annotated"; - } - - @Group1 - @PostMapping("/annotated") - public String annotatedPost() { - return "annotated"; - } - - @Group2 - @PutMapping("/annotated") - public String annotatedPut() { - return "annotated"; - } - - - @Bean - public GroupedOpenApi group1OpenApi() { - Predicate hidingCondition = method -> method.isAnnotationPresent(Group1.class); - return GroupedOpenApi.builder() - .group("annotatedGroup1") - .addOperationCustomizer(getOperationCustomizer(hidingCondition)) - .build(); - } - - @Bean - public GroupedOpenApi group2OpenApi() { - Predicate filterCondition = method -> method.isAnnotationPresent(Group2.class); - return GroupedOpenApi.builder() - .group("annotatedGroup2") - .addOperationCustomizer(getOperationCustomizer(filterCondition)) - .build(); - } - - @Bean - public GroupedOpenApi group3OpenApi() { - Predicate hidingCondition = method -> method.isAnnotationPresent(Group1.class) || method.isAnnotationPresent(Group2.class); - return GroupedOpenApi.builder() - .group("annotatedCombinedGroup") - .addOperationCustomizer(getOperationCustomizer(hidingCondition)) - .build(); - } - - private OperationCustomizer getOperationCustomizer(Predicate filterCondition) { - return (operation, handlerMethod) -> filterCondition.test(handlerMethod.getMethod()) ? operation : null; - } - - @Retention(RetentionPolicy.RUNTIME) - @interface Group1 { - - } - - @Retention(RetentionPolicy.RUNTIME) - @interface Group2 { - - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/HelloController.java deleted file mode 100644 index 9eee0c6b7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/HelloController.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app179; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -public class HelloController { - @GetMapping("/test/{objId}") - String test(@MyIdPathVariable MyObj obj) { - return obj.getContent(); - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyConfiguration.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyConfiguration.java deleted file mode 100644 index 3409de162..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyConfiguration.java +++ /dev/null @@ -1,15 +0,0 @@ -package test.org.springdoc.api.app179; - -import java.util.List; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.method.support.HandlerMethodArgumentResolver; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -@Configuration -public class MyConfiguration implements WebMvcConfigurer { - @Override - public void addArgumentResolvers(List resolvers) { - resolvers.add(new MyObjArgumentResolver()); - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyIdPathVariable.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyIdPathVariable.java deleted file mode 100644 index 6b1860be2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyIdPathVariable.java +++ /dev/null @@ -1,11 +0,0 @@ -package test.org.springdoc.api.app179; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.PARAMETER) -public @interface MyIdPathVariable { -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyObj.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyObj.java deleted file mode 100644 index 4a25da205..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyObj.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app179; - -public class MyObj { - private final String id; - private final String content; - - public MyObj(String id, String content) { - this.id = id; - this.content = content; - } - - public String getId() { - return id; - } - - public String getContent() { - return content; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyObjArgumentResolver.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyObjArgumentResolver.java deleted file mode 100644 index 7ce83a79a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyObjArgumentResolver.java +++ /dev/null @@ -1,23 +0,0 @@ -package test.org.springdoc.api.app179; - -import org.springframework.core.MethodParameter; -import org.springframework.web.bind.support.WebDataBinderFactory; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.method.support.HandlerMethodArgumentResolver; -import org.springframework.web.method.support.ModelAndViewContainer; - - -public class MyObjArgumentResolver implements HandlerMethodArgumentResolver { - - @Override - public boolean supportsParameter(MethodParameter parameter) { - return parameter.hasParameterAnnotation(MyIdPathVariable.class) && - MyObj.class.isAssignableFrom(parameter.getParameterType()); - } - - @Override - public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, - NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { - return new MyObj("id", "content"); - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyPathParameterCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyPathParameterCustomizer.java deleted file mode 100644 index edfed5b76..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/MyPathParameterCustomizer.java +++ /dev/null @@ -1,23 +0,0 @@ -package test.org.springdoc.api.app179; - -import io.swagger.v3.oas.models.media.StringSchema; -import io.swagger.v3.oas.models.parameters.Parameter; -import io.swagger.v3.oas.models.parameters.PathParameter; -import org.springdoc.core.customizers.ParameterCustomizer; - -import org.springframework.core.MethodParameter; -import org.springframework.stereotype.Component; - -@Component -public class MyPathParameterCustomizer implements ParameterCustomizer { - @Override - public Parameter customize(Parameter parameterModel, MethodParameter methodParameter) { - if (methodParameter.hasParameterAnnotation(MyIdPathVariable.class)) { - Parameter alternativeParameter = new PathParameter(); - alternativeParameter.setName("objId"); - alternativeParameter.setSchema(new StringSchema()); - return alternativeParameter; - } - return parameterModel; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/SpringDocApp179Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/SpringDocApp179Test.java deleted file mode 100644 index b06738036..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app179/SpringDocApp179Test.java +++ /dev/null @@ -1,11 +0,0 @@ -package test.org.springdoc.api.app179; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp179Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app18/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app18/HelloController.java deleted file mode 100644 index 9cb1b085b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app18/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.app18; - -import javax.validation.constraints.NegativeOrZero; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.PositiveOrZero; - -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; - -@RestController -public class HelloController { - - @GetMapping(value = "/persons") - public String persons(@NotBlank String name) { - return "OK"; - } - - @GetMapping(value = "/persons2") - public String persons2(@NotBlank @Parameter(description = "persons name") String name) { - return "OK"; - } - - @GetMapping(value = "/persons3") - public String persons3(@NotBlank @Parameter(description = "persons name") @RequestParam String name) { - return "OK"; - } - - @GetMapping(value = "/persons4") - public String persons4(@PositiveOrZero int age) { - return "OK"; - } - - @GetMapping(value = "/persons5") - public String persons5(@NegativeOrZero int age) { - return "OK"; - } - - @GetMapping(value = "/persons6") - public String persons6(@NotEmpty @Parameter(description = "persons name") String name) { - return "OK"; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app18/SpringDocApp18Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app18/SpringDocApp18Test.java deleted file mode 100644 index b4a07fcf2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app18/SpringDocApp18Test.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.app18; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.pre-loading-enabled=true") -public class SpringDocApp18Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app180/Body.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app180/Body.java deleted file mode 100644 index f0db2d0ac..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app180/Body.java +++ /dev/null @@ -1,83 +0,0 @@ -package test.org.springdoc.api.app180; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -import io.swagger.v3.oas.annotations.media.Schema; - - -@Schema(name = "Body", description = "Body", example = "{\"key\":\"value\"}") -public class Body implements Map, MapExclusion { - - @Schema(hidden = true) - private Map data; - - public Map getData() { - return data; - } - - public void setData(Map data) { - this.data = data; - } - - @Override - public int size() { - return 0; - } - - @Override - public boolean isEmpty() { - return false; - } - - @Override - public boolean containsKey(Object key) { - return false; - } - - @Override - public boolean containsValue(Object value) { - return false; - } - - @Override - public Object get(Object key) { - return null; - } - - @Override - public Object put(String key, Object value) { - return null; - } - - @Override - public Object remove(Object key) { - return null; - } - - @Override - public void putAll(Map m) { - - } - - @Override - public void clear() { - - } - - @Override - public Set keySet() { - return null; - } - - @Override - public Collection values() { - return null; - } - - @Override - public Set> entrySet() { - return null; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app180/MapExclusion.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app180/MapExclusion.java deleted file mode 100644 index 316a0514f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app180/MapExclusion.java +++ /dev/null @@ -1,8 +0,0 @@ -package test.org.springdoc.api.app180; - -import com.fasterxml.jackson.annotation.JsonIgnore; - -public interface MapExclusion { - @JsonIgnore - boolean isEmpty(); -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app180/RESTService.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app180/RESTService.java deleted file mode 100644 index 830da5d18..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app180/RESTService.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api.app180; - -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.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; - -@RestController -@RequestMapping("api") -@Tag(name = "REST Service") -public class RESTService { - - @PostMapping("/testWithoutSchema") - @Operation(summary = "Test Request Body type Schema usage [Error]") - public String withoutSchema(@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true) - @RequestBody Body body) { - return "without proper schema"; - } - - @PostMapping("/testWithSchema") - @Operation(summary = "Test Request Body type Schema usage [Correct]") - public String withSchema(@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = @Content(schema = @Schema(implementation = Body.class))) - @RequestBody Body body) { - return "with proper schema"; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app181/AbstractParameterObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app181/AbstractParameterObject.java deleted file mode 100644 index 9e9837281..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app181/AbstractParameterObject.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app181; - -public class AbstractParameterObject { - - int primitiveBaseField; - - T genericField; - - public int getPrimitiveBaseField() { - return primitiveBaseField; - } - - public void setPrimitiveBaseField(int primitiveBaseField) { - this.primitiveBaseField = primitiveBaseField; - } - - public T getGenericField() { - return genericField; - } - - public void setGenericField(T genericField) { - this.genericField = genericField; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app181/ConcreteParameterObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app181/ConcreteParameterObject.java deleted file mode 100644 index 7684c6ed9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app181/ConcreteParameterObject.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app181; - -public class ConcreteParameterObject extends AbstractParameterObject { - - int primitiveConcreteField; - - public int getPrimitiveConcreteField() { - return primitiveConcreteField; - } - - public void setPrimitiveConcreteField(int primitiveConcreteField) { - this.primitiveConcreteField = primitiveConcreteField; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app181/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app181/HelloController.java deleted file mode 100644 index c2502a6fd..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app181/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.app181; - -import org.springdoc.api.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 -public class HelloController { - - @GetMapping( "/test1") - public ResponseEntity sayHello( @ParameterObject final ConcreteParameterObject 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-webmvc-core/src/test/java/test/org/springdoc/api/app181/SpringDocApp181Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app181/SpringDocApp181Test.java deleted file mode 100644 index a2169de0a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app181/SpringDocApp181Test.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.app181; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -public class SpringDocApp181Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app182/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app182/HelloController.java deleted file mode 100644 index 5cd36652e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app182/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.app182; - -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; - -@RestController -public class HelloController { - - @ExceptionHandler(IllegalArgumentException.class) - @ApiResponse(responseCode = "404", description = "Not here", content = @Content) - @ResponseStatus(HttpStatus.NOT_FOUND) - public void bad(IllegalArgumentException e) { - - } - - @ExceptionHandler(RuntimeException.class) - @ResponseStatus(HttpStatus.BAD_GATEWAY) - public Object gateway(RuntimeException e) { - return null; - } - - @GetMapping(value = "/hello/{numTelco}") - @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) - public T index(@PathVariable("numTelco") String numTel, String adresse) { - throw new IllegalArgumentException(); - - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app182/SpringDocApp182Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app182/SpringDocApp182Test.java deleted file mode 100644 index b34c5d436..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app182/SpringDocApp182Test.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.app182; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Copy of 124 without RestControllerAdvice class - */ -public class SpringDocApp182Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/HelloController.java deleted file mode 100644 index 7da9d7813..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/HelloController.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.org.springdoc.api.app183; - -import io.swagger.v3.oas.annotations.tags.Tag; - -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 -@Tag(name = "NetworkServices", description = "the NetworkServices API") -public class HelloController { - - - - - @GetMapping("/{userId}") - public User doSomething(@PathVariable("userId") User user) { - return new User(user.getId(), "tototot"); - } - - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/SpringDocApp183Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/SpringDocApp183Test.java deleted file mode 100644 index f242af7b6..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/SpringDocApp183Test.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.app183; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp183Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/User.java deleted file mode 100644 index 17327962a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/User.java +++ /dev/null @@ -1,41 +0,0 @@ -package test.org.springdoc.api.app183; - -public class User { - - String id; - - String toto; - - - public User() { - } - - public User(String id, String toto) { - this.id = id; - this.toto = toto; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getToto() { - return toto; - } - - public void setToto(String toto) { - this.toto = toto; - } - - @Override - public String toString() { - return "User{" + - "id='" + id + '\'' + - ", toto='" + toto + '\'' + - '}'; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/UserConverter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/UserConverter.java deleted file mode 100644 index a42276d23..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/UserConverter.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app183; - -import org.springframework.core.convert.converter.Converter; - -public class UserConverter implements Converter { - - @Override - public User convert(String userId) { - // Fetch from repository - User user = new User(); - user.setId(userId); - return user; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/WebConfig.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/WebConfig.java deleted file mode 100644 index 93cd8d261..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app183/WebConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -package test.org.springdoc.api.app183; - -import org.springframework.context.annotation.Configuration; -import org.springframework.format.FormatterRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -@Configuration -public class WebConfig implements WebMvcConfigurer { - - @Override - public void addFormatters(FormatterRegistry registry) { - registry.addConverter(new UserConverter()); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app184/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app184/HelloController.java deleted file mode 100644 index a38bd2590..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app184/HelloController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2022 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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-webmvc-core/src/test/java/test/org/springdoc/api/app185/Cat.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/Cat.java deleted file mode 100644 index eeff6f564..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/Cat.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app185; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class Cat extends Pet { - - private final boolean meows; - - public Cat() { - super(); - this.meows = false; - } - - public Cat(boolean meows, String name) { - super(name); - this.meows = meows; - } - - public boolean getMeows() { - return meows; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/Dog.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/Dog.java deleted file mode 100644 index df8e9838f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/Dog.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app185; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class Dog extends Pet { - - private final boolean barks; - - public Dog() { - super(); - this.barks = false; - } - - public Dog(boolean barks, String name) { - super(name); - this.barks = barks; - } - - public boolean getBarks() { - return barks; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/Pet.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/Pet.java deleted file mode 100644 index fbd640315..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/Pet.java +++ /dev/null @@ -1,23 +0,0 @@ -package test.org.springdoc.api.app185; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") -@JsonSubTypes({ - @JsonSubTypes.Type(Dog.class), - @JsonSubTypes.Type(Cat.class) -}) -public class Pet { - - public final String name; - - public Pet() { - this.name = null; - } - - public Pet(String name) { - this.name = name; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/PetController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/PetController.java deleted file mode 100644 index b69a4ed16..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/PetController.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app185; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class PetController { - - @GetMapping("/any") - public Pet getAnyPet() { - return new Cat(true, "cat"); - } - - @GetMapping("/dog") - public Dog getDog() { - return new Dog(true, "dog"); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/SpringDocApp185Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/SpringDocApp185Test.java deleted file mode 100644 index 63e94241e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app185/SpringDocApp185Test.java +++ /dev/null @@ -1,12 +0,0 @@ -package test.org.springdoc.api.app185; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp185Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app19/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app19/HelloController.java deleted file mode 100644 index 038d3a87a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app19/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.app19; - -import javax.validation.constraints.NotBlank; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.parameters.RequestBody; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @PostMapping(value = "/persons") - public String persons(@RequestBody(description = "requestBody description as parameter") String name) { - return "OK"; - } - - @RequestBody(description = "requestBody description outside") - @PostMapping(value = "/persons2") - public String persons2(String name) { - return "OK"; - } - - @Operation(requestBody = @RequestBody(description = "requestBody inside operation annotation")) - @PostMapping(value = "/persons3") - public String persons3(@NotBlank String name) { - return "OK"; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app19/SpringDocApp19Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app19/SpringDocApp19Test.java deleted file mode 100644 index 29eb576a5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app19/SpringDocApp19Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java deleted file mode 100644 index f7db0612f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.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.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; - -public class SpringDocApp2Test extends AbstractSpringDocTest { - - @SpringBootApplication - 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("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-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/ApiUtil.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/ApiUtil.java deleted file mode 100644 index 92cfb81ec..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/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.app2.api; - -import java.io.IOException; - -import javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/ExceptionTranslator.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/ExceptionTranslator.java deleted file mode 100644 index 84305383e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/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.app2.api; - -import java.util.Map; - -import javax.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("javax.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); - return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/HomeController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/HomeController.java deleted file mode 100644 index 50f3d110e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/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.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/PetApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/PetApi.java deleted file mode 100644 index e1ff96749..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/PetApi.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. - * - */ - -/** - * 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 javax.validation.Valid; -import javax.validation.constraints.NotNull; - -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 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; - -@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-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/PetApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/PetApiController.java deleted file mode 100644 index d42477dee..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/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.app2.api; - -import java.util.Optional; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -@javax.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:/}") -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-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/PetApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/PetApiDelegate.java deleted file mode 100644 index e1bcdc302..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/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.app2.api; - -import java.util.List; -import java.util.Optional; - -import javax.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. - */ -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/PetApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/PetApiDelegateImpl.java deleted file mode 100644 index da5f45a7a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/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.app2.api; - -import org.springframework.stereotype.Service; - -@Service -public class PetApiDelegateImpl implements PetApiDelegate { - - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/StoreApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/StoreApi.java deleted file mode 100644 index 62e007ad7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/StoreApi.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT 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 javax.validation.Valid; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; - -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 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; - -@javax.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}") - @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); - } - - @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(); - } - - @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); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/StoreApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/StoreApiController.java deleted file mode 100644 index 95c3ed6fb..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/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.app2.api; - -import java.util.Optional; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -@javax.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:/}") -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-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/StoreApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/StoreApiDelegate.java deleted file mode 100644 index 77f3039c9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/StoreApiDelegate.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.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. - */ -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/StoreApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/StoreApiDelegateImpl.java deleted file mode 100644 index e3b865b0b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/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.app2.api; - -import org.springframework.stereotype.Service; - -@Service -public class StoreApiDelegateImpl implements StoreApiDelegate { - - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/UserApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/UserApi.java deleted file mode 100644 index 41fa1fc63..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/UserApi.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. - * - */ - -/** - * 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 javax.validation.Valid; -import javax.validation.constraints.NotNull; - -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 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; - -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/UserApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/UserApiController.java deleted file mode 100644 index b0585ab6b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/UserApiController.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.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; - -@javax.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:/}") -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-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/UserApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/UserApiDelegate.java deleted file mode 100644 index 01a16709a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/UserApiDelegate.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.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. - */ -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/UserApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/UserApiDelegateImpl.java deleted file mode 100644 index 4583ded42..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/api/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.app2.api; - -import org.springframework.stereotype.Service; - -@Service -public class UserApiDelegateImpl implements UserApiDelegate { - - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Body.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Body.java deleted file mode 100644 index 7298a4be1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/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.app2.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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Body1.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Body1.java deleted file mode 100644 index a6f95a42b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/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.app2.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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Category.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Category.java deleted file mode 100644 index 8a1477eb3..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/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.app2.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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/ModelApiResponse.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/ModelApiResponse.java deleted file mode 100644 index 13ad6770a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/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.app2.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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Order.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Order.java deleted file mode 100644 index 9194b6b04..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/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.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; - -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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Pet.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Pet.java deleted file mode 100644 index cbe342ef8..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Pet.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 javax.validation.constraints.NotNull; - -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 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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Tag.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/Tag.java deleted file mode 100644 index aef0fae03..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/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.app2.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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/model/User.java deleted file mode 100644 index 759579b2c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app2/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.app2.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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/app20/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app20/HelloController.java deleted file mode 100644 index 60875312a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app20/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.app20; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; - -import io.swagger.v3.oas.annotations.Hidden; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/persons") - @Hidden - public void persons(@Valid @NotBlank String name) { - - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app20/SpringDocApp20Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app20/SpringDocApp20Test.java deleted file mode 100644 index e81bd7ec0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app20/SpringDocApp20Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app21/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app21/HelloController.java deleted file mode 100644 index b819faa29..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app21/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.app21; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; - -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 org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@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") }))) -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app21/SpringDocApp21Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app21/SpringDocApp21Test.java deleted file mode 100644 index 67c937896..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app21/SpringDocApp21Test.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.app21; - -import test.org.springdoc.api.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 AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app22/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app22/HelloController.java deleted file mode 100644 index 1154ca363..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app22/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.app22; - -import java.util.List; - -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 = "/persons") - public ResponseEntity>> doGet() { - return null; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app22/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app22/PersonDTO.java deleted file mode 100644 index 61eceaa8d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app22/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.app22; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app22/SpringDocApp22Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app22/SpringDocApp22Test.java deleted file mode 100644 index 04159e4b5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app22/SpringDocApp22Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app23/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app23/HelloController.java deleted file mode 100644 index 9b6d5bfd5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app23/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.app23; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; - -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 org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@SecurityScheme(type = SecuritySchemeType.APIKEY, in = SecuritySchemeIn.HEADER, name = "Authorization", paramName = "JWT", description = "A core-auth Bearer token") -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app23/SpringDocApp23Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app23/SpringDocApp23Test.java deleted file mode 100644 index a87e0eca7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app23/SpringDocApp23Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app24/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app24/HelloController.java deleted file mode 100644 index ebdd33706..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app24/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.app24; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; - -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 org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@SecurityScheme(type = SecuritySchemeType.APIKEY, in = SecuritySchemeIn.HEADER, name = "Authorization", description = "A core-auth Bearer token") -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app24/SpringDocApp24Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app24/SpringDocApp24Test.java deleted file mode 100644 index 9cc6e671e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app24/SpringDocApp24Test.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.app24; - -import test.org.springdoc.api.AbstractSpringDocTest; - -public class SpringDocApp24Test extends AbstractSpringDocTest { - - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app24/SpringDocTestApp.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app24/SpringDocTestApp.java deleted file mode 100644 index 337a1c990..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app24/SpringDocTestApp.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.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; - -@SpringBootApplication -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")) - .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-webmvc-core/src/test/java/test/org/springdoc/api/app25/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app25/HelloController.java deleted file mode 100644 index f07a5dbf7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app25/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.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; - -@RestController -public class HelloController { - - @GetMapping(value = "/check") - @ResponseStatus(HttpStatus.OK) - void check() { - } - - @GetMapping(value = "/list") - 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) { - } - - @GetMapping(value = "/secondlist") - 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) { - - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app25/SpringDocApp25Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app25/SpringDocApp25Test.java deleted file mode 100644 index 994fc19ec..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app25/SpringDocApp25Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app26/Bar.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/Bar.java deleted file mode 100644 index c76d4bdf2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/Bar.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.app26; - -public class Bar { - private String bar; - - public String getBar() { - return bar; - } - - public void setBar(String bar) { - this.bar = bar; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/Foo.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/Foo.java deleted file mode 100644 index 2e7ecec62..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/Foo.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.app26; - -public class Foo { - - private String foo; - - public String getFoo() { - return foo; - } - - public void setFoo(String foo) { - this.foo = foo; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/HelloController.java deleted file mode 100644 index 2d768cac4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/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.app26; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @PostMapping(value = "/persons") - public MyModel persons(MyModel myModel) { - return new MyModel(); - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/MyModel.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/MyModel.java deleted file mode 100644 index af669de69..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/MyModel.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 io.swagger.v3.oas.annotations.media.Schema; - -public class MyModel { - - @Schema(description = "Hello", type = "object", oneOf = { Foo.class, Bar.class }) - private Object thing; - - public Object getThing() { - return thing; - } - - public void setThing(Object thing) { - this.thing = thing; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/SpringDocApp26Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/SpringDocApp26Test.java deleted file mode 100644 index bdbe6272b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app26/SpringDocApp26Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app27/Advice.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/Advice.java deleted file mode 100644 index 7b20bc148..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/Advice.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.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; - -@RestControllerAdvice -public class Advice { - - @ExceptionHandler(Exception.class) - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public Foo handleException(Exception ex, WebRequest request) { - return new Foo(); - } - - @ExceptionHandler(MyException.class) - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public Bar handleMyException(MyException ex, WebRequest request) { - return new Bar(); - } - - @Hidden - @ExceptionHandler(Throwable.class) - @ResponseStatus(HttpStatus.NOT_FOUND) - public Bar handleMyException2(MyException ex, WebRequest request) { - return new Bar(); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/Bar.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/Bar.java deleted file mode 100644 index 2d0b32a97..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/Bar.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; - -public class Bar { - public String bar = "bar"; -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/Foo.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/Foo.java deleted file mode 100644 index 2bbdf99ab..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/Foo.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; - -public class Foo { - public String foo = "foo"; -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/HelloController.java deleted file mode 100644 index 600d66c95..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/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.app27; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - private boolean flag = false; - - @RequestMapping("/") - public String index() { - return ""; - } - - @GetMapping("/test") - public String test() { - flag = !flag; - throw flag ? new MyException() : new RuntimeException(); - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/MyException.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/MyException.java deleted file mode 100644 index 02553ba2e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/MyException.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.app27; - -public class MyException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = 1L; - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/SpringDocApp27Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/SpringDocApp27Test.java deleted file mode 100644 index 95821c9e2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app27/SpringDocApp27Test.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.app27; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.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; - -public class SpringDocApp27Test extends AbstractSpringDocTest { - - @Test - public 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"))); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app28/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app28/HelloController.java deleted file mode 100644 index 79be6d40d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app28/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app28/SpringDocApp28Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app28/SpringDocApp28Test.java deleted file mode 100644 index b6c7d7786..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app28/SpringDocApp28Test.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.app28; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp28Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app29/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app29/HelloController.java deleted file mode 100644 index 24ddb0040..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app29/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app29/SpringDocApp29Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app29/SpringDocApp29Test.java deleted file mode 100644 index d1ff8f562..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app29/SpringDocApp29Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app29/TrackerData.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app29/TrackerData.java deleted file mode 100644 index d9e849926..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app29/TrackerData.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.app29; - -import java.time.Instant; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(name = "TrackerData") -public class TrackerData { - - @Schema(name = "trackerId", type = "string", required = true, example = "the-tracker-id") - @JsonProperty("trackerId") - String trackerId; - - @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") - @JsonProperty("timestamp") - Instant timestamp; - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app30/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app30/HelloController.java deleted file mode 100644 index f900e4605..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app30/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app30/SpringDocApp30Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app30/SpringDocApp30Test.java deleted file mode 100644 index c308acd49..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app30/SpringDocApp30Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app31/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app31/HelloController.java deleted file mode 100644 index df4a41e62..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app31/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.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; - -@RestController -public class HelloController { - - @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; - } - - static class SubscriptionResponse { - private String subscriptionUuid; - - public String getSubscriptionUuid() { - return subscriptionUuid; - } - - public void setSubscriptionUuid(String subscriptionUuid) { - this.subscriptionUuid = subscriptionUuid; - } - - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app31/SpringDocApp31Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app31/SpringDocApp31Test.java deleted file mode 100644 index 319833b86..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app31/SpringDocApp31Test.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.app31; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp31Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app32/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app32/HelloController.java deleted file mode 100644 index b987e1130..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app32/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.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; - -@RestController -public class HelloController { - - @RequestMapping(value = "/filter", method = RequestMethod.POST) - @ResponseStatus(value = HttpStatus.OK) - public String filterPost(@RequestBody final MyTestDto filter) { - return "OK"; - } - - class MyTestDto { - public String object1; - - public String object2; - - public String object3; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app32/SpringDocApp32Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app32/SpringDocApp32Test.java deleted file mode 100644 index 0b5cb2e76..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app32/SpringDocApp32Test.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.app32; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp32Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app33/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app33/HelloController.java deleted file mode 100644 index 1c62147ee..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app33/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app33/SpringDocApp33Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app33/SpringDocApp33Test.java deleted file mode 100644 index fd93c53be..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app33/SpringDocApp33Test.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.app33; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp33Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app34/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app34/HelloController.java deleted file mode 100644 index 514eaca28..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app34/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app34/MyExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app34/MyExceptionHandler.java deleted file mode 100644 index f9d00d0c8..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app34/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.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; - -@RestControllerAdvice -@Hidden -public class MyExceptionHandler extends ResponseEntityExceptionHandler { - @ExceptionHandler(IllegalArgumentException.class) - @ResponseStatus(HttpStatus.BAD_REQUEST) - public Object bad(IllegalArgumentException e) { - return null; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app34/SpringDocApp34Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app34/SpringDocApp34Test.java deleted file mode 100644 index bf1a971a0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app34/SpringDocApp34Test.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.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-webmvc-core/src/test/java/test/org/springdoc/api/app35/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app35/HelloController.java deleted file mode 100644 index 9b3ae60e0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app35/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.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; - -@Controller -@RequestMapping("/api/v1/poc/") -public class HelloController { - - @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"); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app35/SpringDocApp35Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app35/SpringDocApp35Test.java deleted file mode 100644 index 54c00ba96..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app35/SpringDocApp35Test.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.app35; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import static org.springdoc.core.SpringDocUtils.getConfig; - -public class SpringDocApp35Test extends AbstractSpringDocTest { - - static { - getConfig().addRestControllers(HelloController.class); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app36/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app36/HelloController.java deleted file mode 100644 index b383255fc..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app36/SpringDocApp36Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app36/SpringDocApp36Test.java deleted file mode 100644 index 9f2bf63f0..000000000 --- a/springdoc-openapi-webmvc-core/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.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 - public 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-webmvc-core/src/test/java/test/org/springdoc/api/app37/Bar.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/Bar.java deleted file mode 100644 index cd28e480a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/Bar.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; - -public class Bar { - public String bar = "bar"; -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/Car.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/Car.java deleted file mode 100644 index e89a0aed6..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/Car.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; - -public class Car { - public String car = "car"; - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/Foo.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/Foo.java deleted file mode 100644 index 926e3ced9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/Foo.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; - -public class Foo { - public String foo = "foo"; -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/HelloController.java deleted file mode 100644 index 656576949..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/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.app37; - -import javax.validation.Valid; - -import io.swagger.v3.oas.annotations.parameters.RequestBody; - -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; - -@RestController("/api") -public class HelloController { - - @PostMapping(path = "/bar/baz", consumes = "application/x.a+json", produces = MediaType.TEXT_PLAIN_VALUE) - public Foo process(@RequestBody Foo a) { - return a; - } - - @PostMapping(path = "/bar/baz", consumes = "application/x.b+json", produces = MediaType.TEXT_PLAIN_VALUE) - public Bar process(@RequestBody Bar b) { - return b; - } - - @PostMapping(path = "/bar/baz", consumes = "application/x.c+json", produces = MediaType.APPLICATION_JSON_VALUE) - public Car process(@RequestBody Car c) { - return c; - } - - @PostMapping(value = "/pets", consumes = "application/json") - public ResponseEntity petsPost(@Valid @RequestBody Pet pet) { - return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); - } - - @PostMapping(value = "/pets", consumes = "text/plain") - public ResponseEntity petsPost(@Valid @RequestBody String pet) { - return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/Pet.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/Pet.java deleted file mode 100644 index 6e0d12d84..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/Pet.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; - -public class Pet { - public String pet = "pet"; - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/SpringDocApp37Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/SpringDocApp37Test.java deleted file mode 100644 index 021eb3e90..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app37/SpringDocApp37Test.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; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp37Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app38/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app38/HelloController.java deleted file mode 100644 index f94570b92..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app38/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.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; - -@RestController("/api") -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app38/SpringDocApp38Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app38/SpringDocApp38Test.java deleted file mode 100644 index 32760f76f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app38/SpringDocApp38Test.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.app38; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp38Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app39/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app39/HelloController.java deleted file mode 100644 index 70ba942f5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app39/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.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; - -@RestController -public class HelloController { - - @Operation(summary = "test Request") - @RequestBody(description = "test value", required = true, content = @Content(schema = @Schema(implementation = String.class))) - @PostMapping("/test") - public void searchEmployee(String test) { - } - - @GetMapping("/hello") - public String hello() { - return "hello"; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app39/SpringDocApp39Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app39/SpringDocApp39Test.java deleted file mode 100644 index 4c346c559..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app39/SpringDocTestApp.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app39/SpringDocTestApp.java deleted file mode 100644 index 0f42f4a7d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app39/SpringDocTestApp.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.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.OpenApiCustomiser; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -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 OpenApiCustomiser customerGlobalHeaderOpenApiCustomiser() { - 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-webmvc-core/src/test/java/test/org/springdoc/api/app4/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app4/HelloController.java deleted file mode 100644 index 8220a9a65..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app4/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.app4; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @PostMapping(value = "/values/data") - TrackerData list(TrackerData toto) { - return toto; - - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java deleted file mode 100644 index 53ec8d6b1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.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 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; - -@TestPropertySource(properties = "springdoc.use-fqn=true") -public class SpringDocApp4Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - - @AfterAll - static void restore(){ - TypeNameResolver.std.setUseFqn(false); - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app4/TrackerData.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app4/TrackerData.java deleted file mode 100644 index ba52b70d0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app4/TrackerData.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.app4; - -import java.time.Instant; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -public class TrackerData { - - @Schema(name = "trackerId", type = "string", required = true, example = "the-tracker-id") - @JsonProperty("trackerId") - String trackerId; - - @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") - @JsonProperty("timestamp") - Instant timestamp; - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app40/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app40/HelloController.java deleted file mode 100644 index 06ff59b14..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app40/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.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; - -@RestController("/api") -public class HelloController { - - @RequestMapping(value = "/iae_error", method = RequestMethod.GET) - public ObjectNode getStartFormProperties() { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app40/SpringDocApp40Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app40/SpringDocApp40Test.java deleted file mode 100644 index 2a447d32a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app40/SpringDocApp40Test.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.app40; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp40Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app41/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app41/HelloController.java deleted file mode 100644 index 72d11b29a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app41/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.app41; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -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.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; - -@RestController("/api") -public class HelloController { - - @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 = java.lang.Error.class))), - @ApiResponse(responseCode = "500", description = "Unexpected error", content = @Content(schema = @Schema(implementation = java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/app41/SpringDocApp411Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app41/SpringDocApp411Test.java deleted file mode 100644 index c730321bb..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app41/SpringDocApp411Test.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.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.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; - -public class SpringDocApp411Test extends AbstractSpringDocTest { - - @Test - public 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); - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app41/SpringDocApp41Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app41/SpringDocApp41Test.java deleted file mode 100644 index a1bb80319..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app41/SpringDocApp41Test.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.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.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; - -@TestPropertySource(properties = "springdoc.cache.disabled=true") -public class SpringDocApp41Test extends AbstractSpringDocTest { - - @Test - public 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); - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app42/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app42/HelloController.java deleted file mode 100644 index a4f2412b1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app42/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.app42; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - - -@RestController("/api") -public class HelloController { - - @GetMapping(value = "/tweets") - public void tweets(@PathVariable TweetId id) { - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app42/SpringDocApp42Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app42/SpringDocApp42Test.java deleted file mode 100644 index 5124f1b3a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app42/SpringDocApp42Test.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.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; - -public class SpringDocApp42Test extends AbstractSpringDocTest { - - - @SpringBootApplication - static class SpringDocTestApp { - @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-webmvc-core/src/test/java/test/org/springdoc/api/app42/TweetId.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app42/TweetId.java deleted file mode 100644 index 5c48a6648..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app42/TweetId.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.app42; - -public class TweetId { - private final String value; - - public TweetId(String value) { - this.value = value; - } - - public String getValue() { - return value; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app43/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app43/HelloController.java deleted file mode 100644 index b053bb4aa..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app43/HelloController.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.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; - -@RestController -public class HelloController { - - @PostMapping(path = "/documents", consumes = "multipart/form-data") - public ResponseEntity uploadDocuments(@RequestPart("doc") List multipartFiles) { - return null; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app43/SpringDocApp43Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app43/SpringDocApp43Test.java deleted file mode 100644 index ba79089eb..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app43/SpringDocApp43Test.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.app43; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp43Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app44/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app44/HelloController.java deleted file mode 100644 index 57e49226f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app44/HelloController.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; - -@RestController("/api") -public class HelloController { - - @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)); - } - - @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)); - } - - static class RequestV1 { - private String nameV1; - - public RequestV1() { - } - - public String getNameV1() { - return nameV1; - } - - public void setNameV1(String nameV1) { - this.nameV1 = nameV1; - } - } - - static class RequestV2 { - private String nameV2; - - public RequestV2() { - } - - public String getNameV2() { - return nameV2; - } - - public void setNameV2(String nameV2) { - this.nameV2 = nameV2; - } - } - - class HelloDTO1 { - private String message; - - public HelloDTO1(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - } - - class HelloDTO2 { - private String message; - - public HelloDTO2(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - } - - class ErrorDTO { - private String errorMessage; - - public ErrorDTO(String errorMessage) { - this.errorMessage = errorMessage; - } - - public String getErrorMessage() { - return errorMessage; - } - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app44/SpringDocApp44Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app44/SpringDocApp44Test.java deleted file mode 100644 index 2e05cd40b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app44/SpringDocApp44Test.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.app44; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.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; - -public class SpringDocApp44Test extends AbstractSpringDocTest { - - @Test - public 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"))); - - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app45/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app45/HelloController.java deleted file mode 100644 index efb409e03..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app45/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.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; - - -@Tag(name = "People", description = "Use this resource to serve all requests and initiate all operations related to people") -@RestController -@RequestMapping(value = "/v1/people") -public class HelloController { - - - @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); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app45/HelloController2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app45/HelloController2.java deleted file mode 100644 index 460d9a21e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app45/HelloController2.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.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; - - -@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") -public class HelloController2 { - - - @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); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app45/OpenApiConfig.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app45/OpenApiConfig.java deleted file mode 100644 index b720c1b51..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app45/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.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; - -@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-webmvc-core/src/test/java/test/org/springdoc/api/app45/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app45/PersonDTO.java deleted file mode 100644 index d28eef918..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app45/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.app45; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app45/SpringDocApp45Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app45/SpringDocApp45Test.java deleted file mode 100644 index df0766642..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app45/SpringDocApp45Test.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.app45; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp45Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app46/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app46/HelloController.java deleted file mode 100644 index 0e972c3e0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app46/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app46/SpringDocApp46Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app46/SpringDocApp46Test.java deleted file mode 100644 index d7b1d9869..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app46/SpringDocApp46Test.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.app46; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp46Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app47/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app47/HelloController.java deleted file mode 100644 index 7cca1e7a5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app47/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.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; - -@RestController -public class HelloController { - @GetMapping(path = "/documents/{locale}") - public ResponseEntity getDocumentsWithLocale( - @Parameter(schema = @Schema(type = "string")) @PathVariable("locale") Locale locale) { - return null; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app47/SpringDocApp47Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app47/SpringDocApp47Test.java deleted file mode 100644 index 8c01b72d6..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app47/SpringDocApp47Test.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.app47; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp47Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app48/AbstractHelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app48/AbstractHelloController.java deleted file mode 100644 index 9d4c86206..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app48/AbstractHelloController.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.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; - -@ApiResponse(responseCode = "410") -@ApiResponses({ - @ApiResponse(responseCode = "411") -}) -public class AbstractHelloController { - - @GetMapping(path = "/documents/{locale}") - @ApiResponse(responseCode = "412") - @ApiResponses({ - @ApiResponse(responseCode = "413") - }) - public ResponseEntity getDocuments() { - return null; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app48/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app48/HelloController.java deleted file mode 100644 index 2bbf3d664..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app48/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.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; - -@RestController - -@ApiResponse(responseCode = "400") -@ApiResponses({ - @ApiResponse(responseCode = "401") -}) -public class HelloController extends AbstractHelloController { - - @Override - @GetMapping(path = "/documents/{locale}") - @ApiResponse(responseCode = "402") - @ApiResponses({ - @ApiResponse(responseCode = "403") - }) - public ResponseEntity getDocuments() { - return null; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app48/SpringDocApp48Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app48/SpringDocApp48Test.java deleted file mode 100644 index 2165ee475..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app48/SpringDocApp48Test.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.app48; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp48Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app49/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app49/HelloController.java deleted file mode 100644 index 080890eb0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app49/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app49/SpringDocApp49Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app49/SpringDocApp49Test.java deleted file mode 100644 index 6eeaf604a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app49/SpringDocApp49Test.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.app49; - -import test.org.springdoc.api.AbstractSpringDocTest; - -public class SpringDocApp49Test extends AbstractSpringDocTest { - - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app49/SpringDocTestApp.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app49/SpringDocTestApp.java deleted file mode 100644 index 6cf645f30..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app49/SpringDocTestApp.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 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; - -@SpringBootApplication -public class SpringDocTestApp { - - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app5/CustomOpenAPIConfig.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app5/CustomOpenAPIConfig.java deleted file mode 100644 index db1e512cf..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app5/CustomOpenAPIConfig.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.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; - -public class CustomOpenAPIConfig { - @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-webmvc-core/src/test/java/test/org/springdoc/api/app5/sample/OpenApiResourceCustomConfigurationTest.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app5/sample/OpenApiResourceCustomConfigurationTest.java deleted file mode 100644 index 815184642..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app5/sample/OpenApiResourceCustomConfigurationTest.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.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; - -@Import(CustomOpenAPIConfig.class) -@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") -public class OpenApiResourceCustomConfigurationTest extends AbstractSpringDocTest { - - /** - * givenNoConfiguration_whenGetApiJson_returnsDefaultEmptyDocs - should return - * {"openapi":"3.0.1","info":{"title":"Custom API","version":"100"},"paths":{},"components":{}} - */ - @Test - public 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"))); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app5/sample/OpenApiResourceNoConfigurationTest.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app5/sample/OpenApiResourceNoConfigurationTest.java deleted file mode 100644 index 53e7479e7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app5/sample/OpenApiResourceNoConfigurationTest.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.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; - -@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") -public class OpenApiResourceNoConfigurationTest extends AbstractSpringDocTest { - - /** - * givenNoConfiguration_whenGetApiJson_returnsDefaultEmptyDocs - should return - * {"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"paths":{},"components":{}} - */ - @Test - public 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()); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app50/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app50/HelloController.java deleted file mode 100644 index 9e711979a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app50/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app50/SpringDocApp50Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app50/SpringDocApp50Test.java deleted file mode 100644 index 2a2c2338a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app50/SpringDocApp50Test.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.app50; - -import test.org.springdoc.api.AbstractSpringDocTest; - -public class SpringDocApp50Test extends AbstractSpringDocTest { - - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app50/SpringDocTestApp.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app50/SpringDocTestApp.java deleted file mode 100644 index c310dc865..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app50/SpringDocTestApp.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.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; - -@SpringBootApplication -public class SpringDocTestApp { - - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app51/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app51/HelloController.java deleted file mode 100644 index dd81c6f45..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app51/HelloController.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.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; - -@RestController -public class HelloController { - - @Operation(parameters = { - @Parameter(in = ParameterIn.HEADER, name = "test_header", required = true, schema = @Schema(type = "string", example = "rherherherherh")) }) - @GetMapping("/test1") - public String test1() { - return "test"; - } - - @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"; - } - - @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"; - } - - @GetMapping("/test") - public String get( - @PathVariable String path, - @RequestParam(required = false) Map params) { - return null; - } - - @PostMapping - public ResponseEntity> hello(@RequestBody HashMap map) { - return ResponseEntity.ok(map); - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app51/SpringDocApp51Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app51/SpringDocApp51Test.java deleted file mode 100644 index 71323e5d7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app51/SpringDocApp51Test.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.app51; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp51Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app52/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app52/HelloController.java deleted file mode 100644 index 017228ea5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app52/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.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; - -@RestController -public class HelloController { - - @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; - } - - @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; - } - - @PostMapping(value = "/test3", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public String createTest3(@RequestPart("test") MyTestDto test, - @RequestPart("doc") List multipartFiles) { - return null; - } - - class MyTestDto { - public String object1; - - public String object2; - - public String object3; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app52/SpringDocApp52Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app52/SpringDocApp52Test.java deleted file mode 100644 index 66402491e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app52/SpringDocApp52Test.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.app52; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp52Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app53/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app53/HelloController.java deleted file mode 100644 index 312eb5f60..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app53/HelloController.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.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; - -@RestController -public class HelloController { - - @Operation(description = "Some operation") - @GetMapping(value = "/hello1", produces = MediaType.APPLICATION_JSON_VALUE) - List listWithNoApiResponse() { - return null; - } - - @Operation(description = "Some operation") - @ApiResponse - @GetMapping(value = "/hello2", produces = MediaType.APPLICATION_JSON_VALUE) - List listWithEmptyApiResponse() { - return null; - } - - @Operation(description = "Some operation") - @GetMapping(value = "/hello3", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.NO_CONTENT) - List listWithExplicitResponseStatus() { - return null; - } - - @Operation(description = "Some operation") - @GetMapping(value = "/hello4", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.NO_CONTENT) - HelloDTO1 getDTOWithExplicitResponseStatus() { - return null; - } - - @Operation(description = "Some operation") - @GetMapping(value = "/hello5", produces = MediaType.APPLICATION_JSON_VALUE) - List listWithDefaultResponseStatus() { - return null; - } - - @Operation(description = "Some operation") - @GetMapping(value = "/hello6", produces = MediaType.APPLICATION_JSON_VALUE) - HelloDTO1 getDTOWithDefaultResponseStatus() { - return null; - } - - @Operation(description = "Some operation") - @GetMapping(value = "/hello7", produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity getNestedDTOWithDefaultResponseStatus() { - return null; - } - - static class HelloDTO1 { - private String message; - - public HelloDTO1(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app53/HelloControllerWithGlobalApiResponse.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app53/HelloControllerWithGlobalApiResponse.java deleted file mode 100644 index 966189166..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app53/HelloControllerWithGlobalApiResponse.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.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; - -@RestController -@RequestMapping(path = "/global") -public class HelloControllerWithGlobalApiResponse { - - @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; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app53/SpringDocApp53Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app53/SpringDocApp53Test.java deleted file mode 100644 index da703e3f1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app53/SpringDocApp53Test.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.app53; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp53Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app54/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app54/HelloController.java deleted file mode 100644 index 228a81ddf..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app54/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.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; - -@RestController -public class HelloController { - - @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; - } - - @JsonView(Views.MealPartyAdmin.class) - @PostMapping(value = "/parties") - public ResponseEntity saveMealParty(@JsonView(Views.Public.class) @RequestBody MealParty p) { - return null; - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app54/MealParty.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app54/MealParty.java deleted file mode 100644 index 4392f02f5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app54/MealParty.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.app54; - -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonView; - -public class MealParty { - @JsonView(Views.Public.class) - private String name; - - @JsonView(Views.MealPartyAdmin.class) - private List members = new ArrayList<>(); -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app54/SpringDocApp54Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app54/SpringDocApp54Test.java deleted file mode 100644 index 0893de656..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app54/SpringDocApp54Test.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.app54; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp54Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app54/Views.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app54/Views.java deleted file mode 100644 index 27aad5523..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app54/Views.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.app54; - -public interface Views { - public interface Public { - } - - public interface MealPartyAdmin extends Public { - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app55/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app55/HelloController.java deleted file mode 100644 index 769bda7bb..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app55/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.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; - -@Controller -@Tag(name = "health") -public class HelloController { - - /** - * Ping endpoint used for health checks. - */ - @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-webmvc-core/src/test/java/test/org/springdoc/api/app55/SpringDocApp55Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app55/SpringDocApp55Test.java deleted file mode 100644 index 169a1ff9d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app55/SpringDocApp55Test.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.app55; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp55Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app56/GlobalExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app56/GlobalExceptionHandler.java deleted file mode 100644 index a1ba8f585..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app56/GlobalExceptionHandler.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.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; - -@RestControllerAdvice -public class GlobalExceptionHandler { - @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: "); - } - - class ErrorDTO { - private String errorMessage; - - ErrorDTO(String errorMessage) { - this.errorMessage = errorMessage; - } - - public String getErrorMessage() { - return errorMessage; - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app56/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app56/HelloController.java deleted file mode 100644 index fe86f46eb..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app56/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.app56; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app56/SpringDocApp56Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app56/SpringDocApp56Test.java deleted file mode 100644 index c22be61a1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app56/SpringDocApp56Test.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.app56; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp56Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app57/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app57/HelloController.java deleted file mode 100644 index 7a9b13e8e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app57/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.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; - -@RestController -public class HelloController { - - @GetMapping("/{name:.+}") - public ResponseEntity getText(@Parameter(description = "desc", required = true) @PathVariable String name) { - return null; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app57/SpringDocApp57Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app57/SpringDocApp57Test.java deleted file mode 100644 index 54d1523e1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app57/SpringDocApp57Test.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.app57; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp57Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app58/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app58/HelloController.java deleted file mode 100644 index ecb7e6ca6..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app58/HelloController.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.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; - -@RestController -public class HelloController { - - @PostMapping("/examplePost") - @Operation(summary = "schema example") - public Object example(@Parameter(schema = @Schema(hidden = true)) JsonNode json) { - return null; - } - - @GetMapping("/example") - public void test(@Parameter(schema = @Schema(hidden = true)) JsonNode json) { - } - - @GetMapping(value = "/foo") - public void foobar(@Parameter(description = "User", name = "user", - schema = @Schema(implementation = PersonDTO.class)) @RequestParam("bar") String 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) { - - } - - 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-webmvc-core/src/test/java/test/org/springdoc/api/app58/SpringDocApp58Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app58/SpringDocApp58Test.java deleted file mode 100644 index 74946e55b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app58/SpringDocApp58Test.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.app58; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp58Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/HelloBody.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/HelloBody.java deleted file mode 100644 index d097d98fc..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/HelloBody.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app59; - -import javax.validation.constraints.NotNull; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class HelloBody { - - @NotNull - @JsonProperty - private String helloValue; - - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/HelloController.java deleted file mode 100644 index fb3e6501c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/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.app59; - -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.validation.annotation.Validated; -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 { - @Deprecated - @GetMapping("/example") - public void test() { - } - - @PostMapping("/hello") - @ApiResponse(responseCode = "200", description = "The server accepted your hello.") - String hello(@Validated @RequestBody final HelloBody helloBody) { - return "World!"; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/HelloController2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/HelloController2.java deleted file mode 100644 index dec88c772..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/HelloController2.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.app59; - -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.validation.annotation.Validated; -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 -@Deprecated -public class HelloController2 { - - @GetMapping("/example2") - public void test() { - } - - @PostMapping("/hello2") - @ApiResponse(responseCode = "200", description = "The server accepted your hello.") - String hello(@Validated @RequestBody final HelloBody helloBody) { - return "World!"; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/HelloExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/HelloExceptionHandler.java deleted file mode 100644 index 384293c09..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/HelloExceptionHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -package test.org.springdoc.api.app59; - -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.springframework.web.context.request.WebRequest; -import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; - -@Order(Ordered.HIGHEST_PRECEDENCE) -@RestControllerAdvice -public class HelloExceptionHandler extends ResponseEntityExceptionHandler { - - @ExceptionHandler(Exception.class) - @ResponseBody - @ApiResponse(responseCode = "500", - description = "An unknown error occurred" - ) - protected ResponseEntity handleException() { - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - - @Override - @ApiResponse(responseCode = "400", - description = "The request is malformed or information is missing." - ) - protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/SpringDocApp59Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/SpringDocApp59Test.java deleted file mode 100644 index ac2fe428a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app59/SpringDocApp59Test.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.app59; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp59Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app6/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app6/HelloController.java deleted file mode 100644 index 03ce2238c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app6/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java deleted file mode 100644 index 167bf89fd..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.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.app6; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp6Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app60/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app60/HelloController.java deleted file mode 100644 index 7d2a5dd6a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app60/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.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; - -@RestController -public class HelloController { - - @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; - } - - @GetMapping("/hello2") - @Operation(summary = "summary2") - @QuerySort - @QueryPaging - public List list2(String page, String size, String sort) { - return null; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app60/QueryPaging.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app60/QueryPaging.java deleted file mode 100644 index 207c2b55e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app60/QueryPaging.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.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; - -@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-webmvc-core/src/test/java/test/org/springdoc/api/app60/QuerySort.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app60/QuerySort.java deleted file mode 100644 index 81116278a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app60/QuerySort.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.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; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD }) -@Parameter(name = "sort", description = "desc sort from Annotated interface") -public @interface QuerySort { -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app60/SpringDocApp60Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app60/SpringDocApp60Test.java deleted file mode 100644 index 36c2f20f2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app60/SpringDocApp60Test.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.app60; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp60Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app61/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app61/HelloController.java deleted file mode 100644 index 5398978f4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app61/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.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; - -@RestController -public class HelloController { - - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app61/SpringDocApp61Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app61/SpringDocApp61Test.java deleted file mode 100644 index 50f1aa219..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app61/SpringDocApp61Test.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.app61; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp61Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app62/BaseController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app62/BaseController.java deleted file mode 100644 index 310d3f415..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app62/BaseController.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.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; - -@Target({ ElementType.METHOD, ElementType.TYPE }) -@Retention(RetentionPolicy.RUNTIME) -@RestController -@RequestMapping -public @interface BaseController { - @AliasFor(annotation = RequestMapping.class) - String[] value() default {}; - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app62/SpringDocApp62Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app62/SpringDocApp62Test.java deleted file mode 100644 index 2424be32f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app62/SpringDocApp62Test.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.app62; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp62Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app62/TestController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app62/TestController.java deleted file mode 100644 index 7be487f4c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app62/TestController.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.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; - -@BaseController -@Tag(name = "Test Controller") -public class TestController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app63/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app63/HelloController.java deleted file mode 100644 index d5739a9eb..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app63/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.app63; - -import java.util.Locale; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app63/SpringDocApp63Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app63/SpringDocApp63Test.java deleted file mode 100644 index 55a0c859d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app63/SpringDocApp63Test.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.app63; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - - -@TestPropertySource(properties = { - "springdoc.packagesToScan=hell,hello1, hello.me", - "springdoc.packagesToExclude=test.org.springdoc.api.app63.65" }) -public class SpringDocApp63Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app64/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app64/HelloController.java deleted file mode 100644 index 0245f3a24..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app64/SpringDocApp64Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app64/SpringDocApp64Test.java deleted file mode 100644 index 30f097272..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app64/SpringDocApp64Test.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.app64; - -import test.org.springdoc.api.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 AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app65/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app65/HelloController.java deleted file mode 100644 index 3896d2de0..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app65/SpringDocApp65Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app65/SpringDocApp65Test.java deleted file mode 100644 index 490fcec97..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app65/SpringDocApp65Test.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.app65; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp65Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app66/DefaultHealthCheckApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app66/DefaultHealthCheckApi.java deleted file mode 100644 index 75e207879..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app66/DefaultHealthCheckApi.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.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; - - -@RestController -@Hidden -public class DefaultHealthCheckApi { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app66/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app66/HelloController.java deleted file mode 100644 index f2afff9f9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app66/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.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; - -@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(UndocumentedClass possiblyInjectedByAspect) { - return ResponseEntity.ok("Healthy"); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app66/SpringDocApp66Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app66/SpringDocApp66Test.java deleted file mode 100644 index 8e3c1efb4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app66/SpringDocApp66Test.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 test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp66Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app66/UndocumentedClass.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app66/UndocumentedClass.java deleted file mode 100644 index 9d22e6d85..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app66/UndocumentedClass.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.app66; - -import io.swagger.v3.oas.annotations.Hidden; - -@Hidden -public class UndocumentedClass { - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app67/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app67/HelloController.java deleted file mode 100644 index e77fd0ea1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app67/HelloController.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. - * - */ - -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; - -@RestController -@RequestMapping(path = "/demo", - produces = MediaType.TEXT_PLAIN_VALUE) -public class HelloController { - - @GetMapping("operation1") - @Operation(summary = "Operation 1 (expected result - no parameters)") - public String operation1() { - return "operation1"; - } - - @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"; - } - - @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"; - } - - @GetMapping("operation4") - @Operation(summary = "Operation 4 (expected result - 3 parameters)") - @QueryPaging - @QuerySort - public String operation4() { - return "operation4"; - } - - @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 { - - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app67/SpringDocApp67Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app67/SpringDocApp67Test.java deleted file mode 100644 index 95d8096eb..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app67/SpringDocApp67Test.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.app67; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp67Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/CustomizedOperation.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/CustomizedOperation.java deleted file mode 100644 index 146b41c33..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app68/SpringDocApp68Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/SpringDocApp68Test.java deleted file mode 100644 index 9062b2596..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/SpringDocApp68Test.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.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 { - - public static String className; - - @Test - public 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 - public 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 - public 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 - public 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 - public 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 - public 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 - public void testApp5() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/user")) - .andExpect(status().isNotFound()); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/SpringDocTestApp.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/SpringDocTestApp.java deleted file mode 100644 index b8f1ce9fb..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/SpringDocTestApp.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.Constants; -import org.springdoc.core.GroupedOpenApi; -import org.springdoc.core.customizers.OpenApiCustomiser; -import org.springdoc.core.customizers.OperationCustomizer; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.web.method.HandlerMethod; - -@SpringBootApplication -public class SpringDocTestApp { - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - @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").addOpenApiCustomiser(serverOpenApiCustomiser1()) - .addOperationCustomizer(operationCustomizer()) - .build(); - } - - public OpenApiCustomiser serverOpenApiCustomiser1() { - Server server = new Server().url("http://toto.v1.com").description("myserver1"); - List servers = new ArrayList<>(); - servers.add(server); - return openApi -> openApi.setServers(servers); - } - - public OpenApiCustomiser serverOpenApiCustomiser2() { - 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/**").addOpenApiCustomiser(serverOpenApiCustomiser2()) - .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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/ApiUtil.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/ApiUtil.java deleted file mode 100644 index a64749c42..000000000 --- a/springdoc-openapi-webmvc-core/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 javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/ExceptionTranslator.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/ExceptionTranslator.java deleted file mode 100644 index 8beeef6a2..000000000 --- a/springdoc-openapi-webmvc-core/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 javax.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("javax.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); - return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/HomeController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/HomeController.java deleted file mode 100644 index 2434d92a2..000000000 --- a/springdoc-openapi-webmvc-core/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.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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/pet/PetApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/pet/PetApi.java deleted file mode 100644 index 43cfae804..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/pet/PetApi.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. - * - */ - -/** - * 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 javax.validation.Valid; -import javax.validation.constraints.NotNull; - -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 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 test.org.springdoc.api.app68.api.pet.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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiController.java deleted file mode 100644 index 012fe00fe..000000000 --- a/springdoc-openapi-webmvc-core/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; - -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiDelegate.java deleted file mode 100644 index 2b28668b2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiDelegate.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 javax.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. - */ -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiDelegateImpl.java deleted file mode 100644 index 5a70c357f..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/store/StoreApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/store/StoreApi.java deleted file mode 100644 index ec1fa1065..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/store/StoreApi.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT 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 javax.validation.Valid; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; - -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 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; - -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiController.java deleted file mode 100644 index 95414794c..000000000 --- a/springdoc-openapi-webmvc-core/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; - -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiDelegate.java deleted file mode 100644 index d37166e6a..000000000 --- a/springdoc-openapi-webmvc-core/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. - */ -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiDelegateImpl.java deleted file mode 100644 index 3e81c002b..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/user/UserApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/user/UserApi.java deleted file mode 100644 index a10fcb498..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/user/UserApi.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. - * - */ - -/** - * 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 javax.validation.Valid; -import javax.validation.constraints.NotNull; - -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 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; - -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/user/UserApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/user/UserApiController.java deleted file mode 100644 index 8ae1ecab2..000000000 --- a/springdoc-openapi-webmvc-core/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; - -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/user/UserApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/user/UserApiDelegate.java deleted file mode 100644 index 022192fc8..000000000 --- a/springdoc-openapi-webmvc-core/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. - */ -@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/user/UserApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/user/UserApiDelegateImpl.java deleted file mode 100644 index dee9cd208..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/user/UserClient.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/user/UserClient.java deleted file mode 100644 index b4e42a00a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/api/user/UserClient.java +++ /dev/null @@ -1,19 +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-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Body.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Body.java deleted file mode 100644 index c2076e97f..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Body1.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Body1.java deleted file mode 100644 index 9fa7c2baf..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Category.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Category.java deleted file mode 100644 index d131574f9..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/ModelApiResponse.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/ModelApiResponse.java deleted file mode 100644 index 521ecb8e6..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Order.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Order.java deleted file mode 100644 index feede5ec3..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Pet.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Pet.java deleted file mode 100644 index acffd6f16..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Pet.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * - * * Copyright 2019-2020 the original author or authors. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 javax.validation.constraints.NotNull; - -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 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-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Tag.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/Tag.java deleted file mode 100644 index 585aec5db..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app68/model/User.java deleted file mode 100644 index 0e3f8c6e2..000000000 --- a/springdoc-openapi-webmvc-core/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-webmvc-core/src/test/java/test/org/springdoc/api/app69/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app69/HelloController.java deleted file mode 100644 index 9a68d888e..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app69/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.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; - -@RestController -public class HelloController { - - @RequestMapping(value = "/tasks", method = RequestMethod.GET) - private Callable> getTasks(String str) { - return null; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app69/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app69/PersonDTO.java deleted file mode 100644 index f8f29765d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app69/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.app69; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app69/SpringDocApp69Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app69/SpringDocApp69Test.java deleted file mode 100644 index d36c637dc..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app69/SpringDocApp69Test.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.app69; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp69Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app7/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app7/HelloController.java deleted file mode 100644 index 1cc629bf4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app7/HelloController.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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java deleted file mode 100644 index 77677b113..000000000 --- a/springdoc-openapi-webmvc-core/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 {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/HelloController.java deleted file mode 100644 index d6e35c924..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/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.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; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app70/SpringDocApp70Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/SpringDocApp70Test.java deleted file mode 100644 index 9fe3f811c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/SpringDocApp70Test.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.app70; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp70Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedOperation.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedOperation.java deleted file mode 100644 index 476879d6b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/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.app70.customizer; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedParameter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedParameter.java deleted file mode 100644 index 111717fab..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedParameter.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.app70.customizer; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface CustomizedParameter { - String addition() default "customized parameter!"; -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedProperty.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedProperty.java deleted file mode 100644 index 0e82dbe8b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedProperty.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.app70.customizer; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface CustomizedProperty { - String addition() default "customized property!"; -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/OperationCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/OperationCustomizer.java deleted file mode 100644 index 385b0d814..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/OperationCustomizer.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.app70.customizer; - -import io.swagger.v3.oas.models.Operation; - -import org.springframework.stereotype.Component; -import org.springframework.web.method.HandlerMethod; - -@Component -public class OperationCustomizer implements org.springdoc.core.customizers.OperationCustomizer { - @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-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/ParameterCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/ParameterCustomizer.java deleted file mode 100644 index d0eeb5bc3..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/ParameterCustomizer.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.app70.customizer; - -import io.swagger.v3.oas.models.parameters.Parameter; - -import org.springframework.core.MethodParameter; -import org.springframework.stereotype.Component; - -@Component -public class ParameterCustomizer implements org.springdoc.core.customizers.ParameterCustomizer { - @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-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/PropertyCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/PropertyCustomizer.java deleted file mode 100644 index 4502215e4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/customizer/PropertyCustomizer.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.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.core.util.Json; -import io.swagger.v3.oas.models.media.Schema; -import io.swagger.v3.oas.models.media.StringSchema; - -import org.springframework.stereotype.Component; - -@Component -public class PropertyCustomizer implements org.springdoc.core.customizers.PropertyCustomizer { - @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 = Json.mapper().constructType(type.getType()); - if (javaType.getRawClass().equals(Duration.class)) { - property = new StringSchema().format("duration").properties(Collections.emptyMap()); - } - return property; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/model/ApiType.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/model/ApiType.java deleted file mode 100644 index 3697ecf80..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app70/model/ApiType.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.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; - -public class ApiType { - @CustomizedProperty - @Schema(description = "Test description") - @JsonProperty("someProperty") - private Duration someProperty; - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app71/Dog.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app71/Dog.java deleted file mode 100644 index e2a1f8854..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app71/Dog.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.app71; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - - -@Schema(name = "Dog") -public class Dog { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app71/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app71/HelloController.java deleted file mode 100644 index aac8e6111..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app71/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.app71; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @PostMapping("/persons") - public String persons(Dog dog) { - return null; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app71/SpringDocApp71Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app71/SpringDocApp71Test.java deleted file mode 100644 index 8c23a3cc1..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app71/SpringDocApp71Test.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.app71; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp71Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app72/CacheAutoConfigurationTest1.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app72/CacheAutoConfigurationTest1.java deleted file mode 100644 index 3745fec4c..000000000 --- a/springdoc-openapi-webmvc-core/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 - public void cache_configuration_loaded_when_not_disabled_explicitly() { - contextRunner - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .doesNotHaveBean("springdocBeanFactoryPostProcessor") - .doesNotHaveBean("multipleOpenApiResource") - ); - } - - @Test - public 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 - public void cache_configurations_successfully_disabled() { - contextRunner - .withPropertyValues("springdoc.cache.disabled=true") - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .hasBean("springdocBeanFactoryPostProcessor") - .doesNotHaveBean("multipleOpenApiResource") - ); - } - - @Test - public 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-webmvc-core/src/test/java/test/org/springdoc/api/app72/GroupAutoConfigurationTest.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app72/GroupAutoConfigurationTest.java deleted file mode 100644 index 83d923c10..000000000 --- a/springdoc-openapi-webmvc-core/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.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 - public 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-webmvc-core/src/test/java/test/org/springdoc/api/app73/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app73/HelloController.java deleted file mode 100644 index 98911d905..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app73/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.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; - - -@RestController -@RequestMapping({ "/{country_code}/persons/", "/persons" }) -public class HelloController { - - @DeleteMapping("/{id}") - @ResponseStatus(HttpStatus.NO_CONTENT) - public void delete(@Parameter(name = "country_code", in = ParameterIn.PATH) String countryCode, @PathVariable("id") String id) { - - } - - @GetMapping("/{id}") - public String get(@Parameter(name = "country_code", in = ParameterIn.PATH) String countryCode, @PathVariable("id") String id) { - return null; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app73/SpringDocApp73Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app73/SpringDocApp73Test.java deleted file mode 100644 index 27150181c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app73/SpringDocApp73Test.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.app73; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp73Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app74/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app74/HelloController.java deleted file mode 100644 index f09f085b6..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app74/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.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; - - -@RestController -public class HelloController { - - @PostMapping("/test") - @RequestBody( - content = @Content( - examples = @ExampleObject( - value = "sample" - ) - ) - ) - public String postMyRequestBody( - String myRequestBody) { - return null; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app74/SpringDocApp74Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app74/SpringDocApp74Test.java deleted file mode 100644 index 64da60a8d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app74/SpringDocApp74Test.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.app74; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp74Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app75/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app75/HelloController.java deleted file mode 100644 index f0f738d47..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app75/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.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; - -@RestController -public class HelloController { - - @PostMapping("/test1") - @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; - } - - @PostMapping("/test2") - @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; - } - - @PostMapping("/test3") - @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-webmvc-core/src/test/java/test/org/springdoc/api/app75/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app75/PersonDTO.java deleted file mode 100644 index 168e38c78..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app75/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.app75; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app75/RestResponseEntityExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app75/RestResponseEntityExceptionHandler.java deleted file mode 100644 index a31630859..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app75/RestResponseEntityExceptionHandler.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.app75; - -import java.util.List; - -import javax.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; - -@ControllerAdvice -public class RestResponseEntityExceptionHandler - extends ResponseEntityExceptionHandler { - @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-webmvc-core/src/test/java/test/org/springdoc/api/app75/SpringDocApp75Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app75/SpringDocApp75Test.java deleted file mode 100644 index 30342d873..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app75/SpringDocApp75Test.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.app75; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp75Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app76/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app76/HelloController.java deleted file mode 100644 index 04eccaea4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app76/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.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; - - -@RestController -public class HelloController { - - @GetMapping("/secure") - @ResponseBody - public String secured() { - return "It works!"; - } - - @GetMapping("/open") - @ResponseBody - @SecurityRequirements - public String open() { - return "It works!"; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app76/SpringDocApp76Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app76/SpringDocApp76Test.java deleted file mode 100644 index 2a8412752..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app76/SpringDocApp76Test.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.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; - -public class SpringDocApp76Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - @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-webmvc-core/src/test/java/test/org/springdoc/api/app77/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app77/HelloController.java deleted file mode 100644 index c7a896470..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app77/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.app77; - -import javax.validation.Valid; - -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 org.hibernate.validator.constraints.NotBlank; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -public class HelloController { - - @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) { - - } - - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app77/SpringDocApp77Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app77/SpringDocApp77Test.java deleted file mode 100644 index e9c2b11f5..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app77/SpringDocApp77Test.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.app77; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp77Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app78/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app78/HelloController.java deleted file mode 100644 index b20ce5899..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app78/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.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; - -@RestController -public class HelloController { - - @RequestMapping(value = "/person1", method = RequestMethod.GET) - private CompletionStage> getPerson1(String str) { - return null; - } - - @RequestMapping(value = "/person2", method = RequestMethod.GET) - private CompletableFuture getPerson2(String str) { - return null; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app78/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app78/PersonDTO.java deleted file mode 100644 index 55d0ade1f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app78/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.app78; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app78/SpringDocApp78Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app78/SpringDocApp78Test.java deleted file mode 100644 index fd6ecef0c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app78/SpringDocApp78Test.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.app78; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp78Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app79/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app79/HelloController.java deleted file mode 100644 index 49403b1ea..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app79/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.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; - -@RestController -public class HelloController { - - @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test") - public String echo(@RequestParam Optional text) { - return text.orElse("not-specified"); - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app79/SpringDocApp79Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app79/SpringDocApp79Test.java deleted file mode 100644 index 94e11f386..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app79/SpringDocApp79Test.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.app79; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -public class SpringDocApp79Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app8/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app8/HelloController.java deleted file mode 100644 index dd71b6d8c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app8/HelloController.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 org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/test") - public void test(String hello) { - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java deleted file mode 100644 index c306b1f55..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.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.app8; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.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; - - -public class SpringDocApp8Test extends AbstractSpringDocTest { - - @Test - public void testApp() throws Exception { - mockMvc.perform(get("/myapp" + Constants.DEFAULT_API_DOCS_URL).contextPath("/myapp")) - .andExpect(status().isOk()); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app80/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app80/HelloController.java deleted file mode 100644 index ea9a745ba..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app80/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.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; - -@RestController -@RequestMapping("/api") -public class HelloController { - - - @RequestMapping(value = "/testpost1", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity testpost1(@RequestBody TestObject dto) throws URISyntaxException { - return ResponseEntity.ok(dto); - } - - @RequestMapping(value = "/testpost2", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity testpost2(@RequestBody TestObject dto) throws URISyntaxException { - return ResponseEntity.ok(dto); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app80/SpringDocApp80Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app80/SpringDocApp80Test.java deleted file mode 100644 index 19a5a7d6c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app80/SpringDocApp80Test.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.app80; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.ActiveProfiles; - -@ActiveProfiles("80") -public class SpringDocApp80Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app80/TestObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app80/TestObject.java deleted file mode 100644 index 13d00c968..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app80/TestObject.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.org.springdoc.api.app80; - -import java.time.LocalDateTime; - -public class TestObject { - public String stringValue; - - public LocalDateTime localDateTime; - - public String getStringValue() { - return stringValue; - } - - public void setStringValue(String stringValue) { - this.stringValue = stringValue; - } - - public LocalDateTime getLocalDateTime() { - return localDateTime; - } - - public void setLocalDateTime(LocalDateTime localDateTime) { - this.localDateTime = localDateTime; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app81/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app81/HelloController.java deleted file mode 100644 index 7163bb300..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app81/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.app81; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app81/SpringDocApp81Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app81/SpringDocApp81Test.java deleted file mode 100644 index 1c2f50f57..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app81/SpringDocApp81Test.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.app81; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.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; - -public class SpringDocApp81Test extends AbstractSpringDocTest { - - @Test - public 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"))); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app82/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app82/HelloController.java deleted file mode 100644 index 44be61824..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app82/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.app82; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app82/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app82/PersonDTO.java deleted file mode 100644 index d409f8a67..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app82/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.app82; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app82/SpringDocApp82Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app82/SpringDocApp82Test.java deleted file mode 100644 index 70553b630..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app82/SpringDocApp82Test.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.app82; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp82Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app83/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app83/HelloController.java deleted file mode 100644 index bd4123872..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app83/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.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; - -@RestController -public class HelloController { - - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app83/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app83/PersonDTO.java deleted file mode 100644 index 0a0dce5a7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app83/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.app83; - -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-webmvc-core/src/test/java/test/org/springdoc/api/app83/SpringDocApp83Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app83/SpringDocApp83Test.java deleted file mode 100644 index 3f275a3d4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app83/SpringDocApp83Test.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.app83; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp83Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app84/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app84/HelloController.java deleted file mode 100644 index d846e321d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app84/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.app84; - -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("/persons") - public String persons() { - return "OK"; - } - - @GetMapping("/persons1") - public String persons(String toto) { - return "OK"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app84/SpringDocApp84Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app84/SpringDocApp84Test.java deleted file mode 100644 index 1c47af232..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app84/SpringDocApp84Test.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.app84; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp84Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app85/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app85/HelloController.java deleted file mode 100644 index 69ecf82f6..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app85/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.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; - -@RestController -@RequestMapping("/api") -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app85/SpringDocApp85Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app85/SpringDocApp85Test.java deleted file mode 100644 index 5a5650a31..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app85/SpringDocApp85Test.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.app85; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp85Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app86/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app86/HelloController.java deleted file mode 100644 index 8742e4087..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app86/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.app86; - -import java.util.Locale; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app86/SpringDocApp86Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app86/SpringDocApp86Test.java deleted file mode 100644 index 01b50d563..000000000 --- a/springdoc-openapi-webmvc-core/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.test.context.TestPropertySource; - -@TestPropertySource(properties = { - "springdoc.packagesToScan=test.org.springdoc.api.app86", - "springdoc.packagesToExclude=test.org.springdoc.api.app86.test" }) -public class SpringDocApp86Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app86/test/HelloController2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app86/test/HelloController2.java deleted file mode 100644 index 446777769..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app86/test/HelloController2.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.app86.test; - -import java.util.Locale; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController2 { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app87/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app87/HelloController.java deleted file mode 100644 index 4aba70ce3..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app87/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.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; - - -@RestController("cookie") -public class HelloController { - - @PutMapping("/{itemId}") - @Operation - public ResponseEntity putItem( - @CookieValue( - name = "cookie" - ) String cookie, - @PathVariable UUID itemId, - @RequestBody Item item - ) { - return ResponseEntity.ok(item); - } - - public static class Item { - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app87/SpringDocApp87Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app87/SpringDocApp87Test.java deleted file mode 100644 index 9bff5e33b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app87/SpringDocApp87Test.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.app87; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp87Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app88/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app88/HelloController.java deleted file mode 100644 index aef78aa12..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app88/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.app88; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/persons") - public String persons() { - return null; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app88/SpringDocApp88Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app88/SpringDocApp88Test.java deleted file mode 100644 index 3283d1668..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app88/SpringDocApp88Test.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.app88; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.auto-tag-classes=false") -public class SpringDocApp88Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app89/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app89/HelloController.java deleted file mode 100644 index 9750e9a6b..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app89/HelloController.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.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; - -@RestController -public class HelloController { - - @Operation(summary = "Get Status") - @GetMapping(value = "/status", produces = MediaType.TEXT_HTML_VALUE) - public ModelAndView getAddress(@PathVariable String id) { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app89/SpringDocApp89Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app89/SpringDocApp89Test.java deleted file mode 100644 index 0b6bffc0c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app89/SpringDocApp89Test.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.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.SpringDocUtils.getConfig; - -@TestPropertySource(properties = "springdoc.model-and-view-allowed=true") -public class SpringDocApp89Test extends AbstractSpringDocTest { - - static { - getConfig().replaceWithSchema(ModelAndView.class, new ObjectSchema()); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app9/MyApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app9/MyApi.java deleted file mode 100644 index 2a09aeaa9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app9/MyApi.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.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; - -@RequestMapping("/myapi") -public interface MyApi { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app9/MyApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app9/MyApiController.java deleted file mode 100644 index 0d1afa747..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app9/MyApiController.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.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; - -@RestController -public class MyApiController implements MyApi { - public String get(String language) { - return language; - } - - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java deleted file mode 100644 index 0eef04838..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.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.app9; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp9Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app90/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app90/HelloController.java deleted file mode 100644 index 7d86e4f5c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app90/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.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; - -@RestController -public class HelloController { - - @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) { - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app90/SpringDocApp90Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app90/SpringDocApp90Test.java deleted file mode 100644 index ef8a5193d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app90/SpringDocApp90Test.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.app90; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -public class SpringDocApp90Test extends AbstractSpringDocTest { - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app90/SpringDocTestApp.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app90/SpringDocTestApp.java deleted file mode 100644 index 3e03ab9b2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app90/SpringDocTestApp.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 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; -import java.util.Map.Entry; - -import io.swagger.v3.oas.models.examples.Example; -import org.springdoc.core.customizers.OpenApiCustomiser; - -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; - -@SpringBootApplication -class SpringDocTestApp { - - @Value("classpath:/500-90.txt") - private Resource http500ExampleResource; - - public static String asString(Resource resource) { - try (Reader reader = new InputStreamReader(resource.getInputStream())) { - return FileCopyUtils.copyToString(reader); - } - catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - @Bean - public OpenApiCustomiser openApiCustomiser(Collection> examples) { - return openAPI -> { - examples.forEach(example -> { - openAPI.getComponents().addExamples(example.getKey(), example.getValue()); - }); - }; - } - - @Bean - public Map.Entry http500Example() { - Example http500Example = new Example(); - Map.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-webmvc-core/src/test/java/test/org/springdoc/api/app90/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app90/User.java deleted file mode 100644 index 1f60a92cc..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app90/User.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.app90; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * User - */ - -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-11-30T09:49:26.034469-01:00[Atlantic/Azores]") - - -public class User { - - @JsonProperty("id") - - private Long id; - - - @JsonProperty("username") - - private String username; - - - @JsonProperty("firstName") - - private String firstName; - - - @JsonProperty("lastName") - - private String lastName; - - - @JsonProperty("email") - - private String email; - - - @JsonProperty("password") - - private String password; - - - @JsonProperty("phone") - - private String phone; - - - @JsonProperty("userStatus") - - private Integer userStatus; - - - public User id(Long id) { - this.id = id; - return this; - } - - - /** - * Get id - * - * @return id - */ - @Schema(example = "10", description = "") - - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - - public User username(String username) { - this.username = username; - return this; - } - - - /** - * Get username - * - * @return username - */ - @Schema(example = "theUser", description = "") - - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - - public User firstName(String firstName) { - this.firstName = firstName; - return this; - } - - - /** - * Get firstName - * - * @return firstName - */ - @Schema(example = "John", description = "") - - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - - public User lastName(String lastName) { - this.lastName = lastName; - return this; - } - - - /** - * Get lastName - * - * @return lastName - */ - @Schema(example = "James", description = "") - - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - - public User email(String email) { - this.email = email; - return this; - } - - - /** - * Get email - * - * @return email - */ - @Schema(example = "john@email.com", description = "") - - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - - public User password(String password) { - this.password = password; - return this; - } - - - /** - * Get password - * - * @return password - */ - @Schema(example = "12345", description = "") - - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - - public User phone(String phone) { - this.phone = phone; - return this; - } - - - /** - * Get phone - * - * @return phone - */ - @Schema(example = "12345", description = "") - - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - - public User userStatus(Integer userStatus) { - this.userStatus = userStatus; - return this; - } - - - /** - * User Status - * - * @return userStatus - */ - @Schema(example = "1", description = "User Status") - - - public Integer getUserStatus() { - return userStatus; - } - - public void setUserStatus(Integer userStatus) { - this.userStatus = userStatus; - } - - - @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); - } - - @Override - public int hashCode() { - return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); - } - - @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). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/Advice.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/Advice.java deleted file mode 100644 index 050eb59f4..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/Advice.java +++ /dev/null @@ -1,68 +0,0 @@ -package test.org.springdoc.api.app91; - -import javax.servlet.http.HttpServletRequest; - -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.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; - -@RestControllerAdvice -public class Advice { - - @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); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app91/ApiError.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/ApiError.java deleted file mode 100644 index 392e28df2..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/ApiError.java +++ /dev/null @@ -1,34 +0,0 @@ -package test.org.springdoc.api.app91; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema( - type = "object", - name = "ApiError", - title = "ApiError", - description = "A consistent response object for sending errors over the wire.") -public class ApiError { - - @Schema(name = "status", description = "The Http Status value", type = "int", nullable = true) - @JsonProperty("status") - private int status; - - @Schema( - name = "errorCode", - description = "An Error Code which can help with identifying issues.", - type = "string", - nullable = true) - @JsonProperty("errorCode") - private String errorCode; - - @Schema(name = "message", description = "The Error Message.", type = "string", nullable = false) - @JsonProperty("message") - private String message; - - public ApiError(int status, String errorCode, String message) { - this.status = status; - this.errorCode = errorCode; - this.message = message; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/Greeting.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/Greeting.java deleted file mode 100644 index 96cf47e1a..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/Greeting.java +++ /dev/null @@ -1,26 +0,0 @@ -package test.org.springdoc.api.app91; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema( - type = "object", - name = "Greeting", - title = "Greeting", - description = "An object containing a greeting message") -public class Greeting { - - - @Schema( - name = "payload", - description = "The greeting value", - type = "string", - nullable = false, - example = "sdfsdfs") - @JsonProperty("payload") - private String payload; - - public Greeting(String payload) { - this.payload = payload; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/GreetingController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/GreetingController.java deleted file mode 100644 index 5e39e430c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/GreetingController.java +++ /dev/null @@ -1,33 +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; - -@RestController -@Tag(name = "Demo", description = "The Demo API") -public class GreetingController { - - @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))); - } - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app91/SpringDocApp91Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/SpringDocApp91Test.java deleted file mode 100644 index f0da41540..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app91/SpringDocApp91Test.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.app91; - - -import test.org.springdoc.api.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 AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app92/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app92/HelloController.java deleted file mode 100644 index 160691f4f..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app92/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.app92; - -import javax.validation.constraints.NotNull; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/test") -public class HelloController { - - @GetMapping - String index(@NotNull String test) { - return null; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app92/ParameterCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app92/ParameterCustomizer.java deleted file mode 100644 index 91c56b6fd..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app92/ParameterCustomizer.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.app92; - -import javax.validation.constraints.NotNull; - -import io.swagger.v3.oas.models.parameters.Parameter; - -import org.springframework.core.MethodParameter; -import org.springframework.stereotype.Component; - -@Component -public class ParameterCustomizer implements org.springdoc.core.customizers.ParameterCustomizer { - @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-webmvc-core/src/test/java/test/org/springdoc/api/app92/SpringDocApp92Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app92/SpringDocApp92Test.java deleted file mode 100644 index 9e6c1387c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app92/SpringDocApp92Test.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.app92; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp92Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/BaseClientModel.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/BaseClientModel.java deleted file mode 100644 index 77f3cee63..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/BaseClientModel.java +++ /dev/null @@ -1,8 +0,0 @@ -package test.org.springdoc.api.app93; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public abstract class BaseClientModel { - @JsonProperty("id") - int id; -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/BaseController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/BaseController.java deleted file mode 100644 index 26df7ab76..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/BaseController.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app93; - -import io.swagger.v3.oas.annotations.Operation; - -import org.springframework.web.bind.annotation.GetMapping; - -public abstract class BaseController { - @Operation - @GetMapping - TClientModel get(TClientModel param) { - return null; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/SpecificClientModel.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/SpecificClientModel.java deleted file mode 100644 index c7488284c..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/SpecificClientModel.java +++ /dev/null @@ -1,8 +0,0 @@ -package test.org.springdoc.api.app93; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class SpecificClientModel extends BaseClientModel { - @JsonProperty("name") - String name; -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/SpecificController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/SpecificController.java deleted file mode 100644 index 078ffff9d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/SpecificController.java +++ /dev/null @@ -1,6 +0,0 @@ -package test.org.springdoc.api.app93; - -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class SpecificController extends BaseController {} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/SpringDocApp93Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/SpringDocApp93Test.java deleted file mode 100644 index f3a8d27f9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app93/SpringDocApp93Test.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.app93; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp93Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app95/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app95/HelloController.java deleted file mode 100644 index 8759a46a9..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app95/HelloController.java +++ /dev/null @@ -1,21 +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; - -@RestController -@RequestMapping("/persons") -public class HelloController { - - @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-webmvc-core/src/test/java/test/org/springdoc/api/app95/SpringDocApp95Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app95/SpringDocApp95Test.java deleted file mode 100644 index 961897e88..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app95/SpringDocApp95Test.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.app95; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.ActiveProfiles; - -@ActiveProfiles("95") -public class SpringDocApp95Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app96/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app96/HelloController.java deleted file mode 100644 index 66bb60f07..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app96/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.app96; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -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("/api1") - String test1(@RequestBody @Min(2) int test) { - return null; - } - - @PostMapping("/api2") - String test2(@RequestBody String test) { - return null; - } - - @PostMapping("/api3") - String test3(@NotNull String test) { - return null; - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app96/SpringDocApp96Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app96/SpringDocApp96Test.java deleted file mode 100644 index ea7ced248..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app96/SpringDocApp96Test.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.app96; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp96Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/HelloController.java deleted file mode 100644 index 009cac4ab..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/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.app97; - -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(value = "/student/header1", headers = "X-API-VERSION=1") - public StudentV1 headerV1() { - return new StudentV1("Bob Charlie"); - } - - @GetMapping(value = "/student/header2", headers = "X-API-VERSION=2") - public StudentV2 headerV2() { - return new StudentV2("Charlie"); - } - - @GetMapping(value = "/student/header3", headers = "X-API-VERSION") - public StudentV3 headerV3() { - return new StudentV3("Tom Charlie"); - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/SpringDocApp97Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/SpringDocApp97Test.java deleted file mode 100644 index babf1c8b0..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/SpringDocApp97Test.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.app97; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp97Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/StudentV1.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/StudentV1.java deleted file mode 100644 index bd35bab14..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/StudentV1.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app97; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class StudentV1 { - - @JsonProperty("name") - private String name; - - public StudentV1(String name) { - this.name = name; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/StudentV2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/StudentV2.java deleted file mode 100644 index 665200fb7..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/StudentV2.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app97; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class StudentV2 { - - @JsonProperty("name") - private String name; - - public StudentV2(String name) { - this.name = name; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/StudentV3.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/StudentV3.java deleted file mode 100644 index aa3fc0b21..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app97/StudentV3.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app97; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class StudentV3 { - - @JsonProperty("name") - private String name; - - public StudentV3(String name) { - this.name = name; - } -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app98/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app98/HelloController.java deleted file mode 100644 index 9f98caefd..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app98/HelloController.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app98; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/persons") - public void persons(@IgnoredAnnotationParameter String name) { - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app98/IgnoredAnnotationParameter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app98/IgnoredAnnotationParameter.java deleted file mode 100644 index 30d795a0d..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app98/IgnoredAnnotationParameter.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.app98; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface IgnoredAnnotationParameter { - String addition() default "customized parameter!"; -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app98/SpringDocApp98Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app98/SpringDocApp98Test.java deleted file mode 100644 index 69915e623..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app98/SpringDocApp98Test.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 org.springdoc.core.SpringDocUtils; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp98Test extends AbstractSpringDocTest { - - static { - SpringDocUtils.getConfig().addAnnotationsToIgnore(IgnoredAnnotationParameter.class); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app99/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app99/HelloController.java deleted file mode 100644 index 3fbb9badc..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app99/HelloController.java +++ /dev/null @@ -1,22 +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; - -@RestController -@RequestMapping("/persons") -public class HelloController { - - @GetMapping - @ApiResponses({ - @ApiResponse(responseCode = "202", description = "${test.app99.operation.persons.response.202.description}") - }) - public void persons() { - - } - -} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app99/SpringDocApp99Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app99/SpringDocApp99Test.java deleted file mode 100644 index a853cb3da..000000000 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app99/SpringDocApp99Test.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.app99; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.ActiveProfiles; - -@ActiveProfiles("99") -public class SpringDocApp99Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocActuatorV30Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocActuatorV30Test.java new file mode 100644 index 000000000..debb82880 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocActuatorV30Test.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.annotation.PostConstruct; + +import test.org.springdoc.api.AbstractCommonTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.client.RestTemplate; + +@TestPropertySource(properties={ "management.endpoints.enabled-by-default=true" }) +public abstract class AbstractSpringDocActuatorV30Test extends AbstractCommonTest { + + @LocalManagementPort + private int managementPort; + + @Autowired + private RestTemplateBuilder restTemplateBuilder; + + protected RestTemplate actuatorRestTemplate; + + @PostConstruct + void init() { + actuatorRestTemplate = restTemplateBuilder + .rootUri("http://localhost:" + this.managementPort).build(); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocV30Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocV30Test.java new file mode 100644 index 000000000..b69d179e4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocV30Test.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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 AbstractSpringDocV30Test extends AbstractCommonTest { + + public static String className; + + @Test + public 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ApiException.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ApiException.java new file mode 100644 index 000000000..0717008db --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ApiException.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 final class ApiException extends Exception { + + private static final long serialVersionUID = 1L; + + @SuppressWarnings("unused") + + private final int code; + + public ApiException(int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ApiOriginFilter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ApiOriginFilter.java new file mode 100644 index 000000000..37b0fc288 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ApiOriginFilter.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletResponse; + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +public class ApiOriginFilter implements javax.servlet.Filter { + @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); + } + + @Override + public void destroy() { + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ApiResponseMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ApiResponseMessage.java new file mode 100644 index 000000000..ef218b89c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ApiResponseMessage.java @@ -0,0 +1,98 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.xml.bind.annotation.XmlTransient; + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +@javax.xml.bind.annotation.XmlRootElement +public class ApiResponseMessage { + public static final int ERROR = 1; + + public static final int WARNING = 2; + + public static final int INFO = 3; + + public static final int OK = 4; + + public static final int TOO_BUSY = 5; + + int code; + + String type; + + String message; + + public ApiResponseMessage() { + } + + 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; + } + + @XmlTransient + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ErrorMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ErrorMessage.java new file mode 100644 index 000000000..4ad53cfcb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ErrorMessage.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 ErrorMessage { + + private String id; + + private String message; + + public ErrorMessage(String id, String message2) { + this.id = id; + this.message = message2; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ExceptionTranslator.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ExceptionTranslator.java new file mode 100644 index 000000000..f1275f326 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ExceptionTranslator.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@ControllerAdvice +public class ExceptionTranslator { + + private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionTranslator.class); + + @ExceptionHandler({ RuntimeException.class }) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity handleRunTimeException(RuntimeException e) { + return error(HttpStatus.INTERNAL_SERVER_ERROR, e); + } + + + 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/HelloController.java new file mode 100644 index 000000000..24020456e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping(value = "/hello/{numTelco}") + @ResponseStatus(HttpStatus.I_AM_A_TEAPOT) + @Tag(name = "${prop.toto}") + 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/HomeController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/HomeController.java new file mode 100644 index 000000000..a1fe8d45f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/HomeController.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/InventoryApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/InventoryApi.java new file mode 100644 index 000000000..869bc1b6a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/InventoryApi.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +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 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; + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +@Tag(name = "inventory") +public interface InventoryApi { + + @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); + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/InventoryApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/InventoryApiController.java new file mode 100644 index 000000000..f00853045 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/InventoryApiController.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.v3.oas.annotations.Parameter; + +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; + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +@RestController +public class InventoryApiController implements InventoryApi { + + + @SuppressWarnings("unused") + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public InventoryApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + 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); + } + + 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); + } + + public String getme(String language) { + return language; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/InventoryItem.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/InventoryItem.java new file mode 100644 index 000000000..16dd28c7c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/InventoryItem.java @@ -0,0 +1,184 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotNull; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.validation.annotation.Validated; + +/** + * InventoryItem + */ +@Validated +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +public class InventoryItem { + @JsonProperty("id") + private UUID id = null; + + @JsonProperty("name") + private String name = null; + + @JsonProperty("releaseDate") + private String releaseDate = null; + + @JsonProperty("manufacturer") + private Manufacturer manufacturer = null; + + public InventoryItem id(UUID id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + **/ + @Schema(example = "d290f1ee-6c54-4b01-90e6-d701748f0851", required = true) + @NotNull + + @Valid + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public InventoryItem name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name + **/ + @Schema(example = "Widget Adapter", required = true) + @NotNull + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public InventoryItem releaseDate(String releaseDate) { + this.releaseDate = releaseDate; + return this; + } + + /** + * Get releaseDate + * + * @return releaseDate + **/ + @Schema(example = "2016-08-29T09:12:33.001Z", required = true) + @NotNull + + public String getReleaseDate() { + return releaseDate; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public InventoryItem manufacturer(Manufacturer manufacturer) { + this.manufacturer = manufacturer; + return this; + } + + /** + * Get manufacturer + * + * @return manufacturer + **/ + @Schema(required = true) + @NotNull + + @Valid + public Manufacturer getManufacturer() { + return manufacturer; + } + + public void setManufacturer(Manufacturer manufacturer) { + this.manufacturer = manufacturer; + } + + + @Override + public boolean equals(java.lang.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); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, releaseDate, manufacturer); + } + + @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). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ItemController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ItemController.java new file mode 100644 index 000000000..4850d997b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ItemController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.Size; + +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 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; + +@RestController +@Tag(name = "items") +public class ItemController { + + @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(); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ItemDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ItemDTO.java new file mode 100644 index 000000000..9ce7c8e90 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ItemDTO.java @@ -0,0 +1,130 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +/** + * @author bnasslahsen + */ +public 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; + + @Deprecated + private int deprecatedPrice; + + /** + * + */ + public ItemDTO() { + } + + /** + * @param description description + * @param price price + */ + public ItemDTO(final String description, final int price) { + this.description = description; + this.price = price; + } + + /** + * @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; + } + + /** + * @return + */ + public String getDescription() { + return description; + } + + /** + * @param description description + */ + public void setDescription(final String description) { + this.description = description; + } + + /** + * @return + */ + public String getItemID() { + return itemID; + } + + /** + * @param itemID itemID + */ + public void setItemID(final String itemID) { + this.itemID = itemID; + } + + /** + * @return + */ + public int getPrice() { + return price; + } + + /** + * @param price price + */ + public void setPrice(final int price) { + this.price = price; + } + + public int getDeprecatedPrice() { + return deprecatedPrice; + } + + public void setDeprecatedPrice(int deprecatedPrice) { + this.deprecatedPrice = deprecatedPrice; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ItemLightDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ItemLightDTO.java new file mode 100644 index 000000000..72c5a1023 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/ItemLightDTO.java @@ -0,0 +1,97 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +/** + * @author bnasslahsen + */ +public 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; + + @Deprecated + private int deprecatedPrice; + + /** + * + */ + public ItemLightDTO() { + } + + public ItemLightDTO(String description, int price) { + super(); + this.description = description; + this.price = price; + } + + /** + * @return + */ + public String getDescription() { + return description; + } + + /** + * @param description description + */ + public void setDescription(final String description) { + this.description = description; + } + + /** + * @return + */ + public int getPrice() { + return price; + } + + /** + * @param price price + */ + public void setPrice(final int price) { + this.price = price; + } + + public int getDeprecatedPrice() { + return deprecatedPrice; + } + + public void setDeprecatedPrice(int deprecatedPrice) { + this.deprecatedPrice = deprecatedPrice; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/Manufacturer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/Manufacturer.java new file mode 100644 index 000000000..06b22733b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/Manufacturer.java @@ -0,0 +1,152 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotNull; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.validation.annotation.Validated; + + +/** + * Manufacturer + */ +@Validated +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +public class Manufacturer { + @JsonProperty("name") + private String name = null; + + @JsonProperty("homePage") + private String homePage = null; + + @JsonProperty("phone") + private String phone = null; + + public Manufacturer name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name + **/ + @Schema(example = "ACME Corporation", required = true) + @NotNull + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Manufacturer homePage(String homePage) { + this.homePage = homePage; + return this; + } + + /** + * Get homePage + * + * @return homePage + **/ + @Schema(example = "https://www.acme-corp.com") + + public String getHomePage() { + return homePage; + } + + public void setHomePage(String homePage) { + this.homePage = homePage; + } + + public Manufacturer phone(String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * + * @return phone + **/ + @Schema(example = "408-867-5309") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + + @Override + public boolean equals(java.lang.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); + } + + @Override + public int hashCode() { + return Objects.hash(name, homePage, phone); + } + + @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). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/PeopleRestService.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/PeopleRestService.java new file mode 100644 index 000000000..47fd1262d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/PeopleRestService.java @@ -0,0 +1,111 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@Tag(name = "people") +public class PeopleRestService { + private Map people = new ConcurrentHashMap<>(); + + @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(); + } + + @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; + } + + @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(); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/PersonDTO.java new file mode 100644 index 000000000..05aba8806 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/PersonDTO.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java new file mode 100644 index 000000000..48ac36995 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +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 AbstractSpringDocV30Test { + + @SpringBootApplication + 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("SpringShop API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app10/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app10/HelloController.java new file mode 100644 index 000000000..b249c77b0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app10/HelloController.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.nio.charset.Charset; +import java.util.Locale; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestAttribute; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/test") + public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, + String hello) { + } + + @GetMapping("/testreq") + public void testRequestAttribute(@RequestAttribute String sample, String s) { + } + + @GetMapping(value = {"/employee"}) + public void getEmployee(Charset test) { + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java new file mode 100644 index 000000000..b2a001dd5 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp10Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app100/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app100/HelloController.java new file mode 100644 index 000000000..654e24ac1 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app100/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotNull; + +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.tags.Tags; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Tags(value = @Tag(name = "hello-ap1")) +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app100/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app100/PersonDTO.java new file mode 100644 index 000000000..1fd9b50f5 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app100/PersonDTO.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app100/SpringDocApp100Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app100/SpringDocApp100Test.java new file mode 100644 index 000000000..38164a42c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app100/SpringDocApp100Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp100Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app101/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app101/HelloController.java new file mode 100644 index 000000000..279f722f9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app101/HelloController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/hello") +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app101/HelloDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app101/HelloDTO.java new file mode 100644 index 000000000..1e9f1fc05 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app101/HelloDTO.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Schema(description = "${test.app101.schema.hello.description}") +public class HelloDTO { + + @Schema(description = "${test.app101.schema.hello.param.id.description}") + private String id; + + @JsonProperty("id") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app101/SpringDocApp101Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app101/SpringDocApp101Test.java new file mode 100644 index 000000000..17fb68a3f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app101/SpringDocApp101Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; + +@ActiveProfiles("101") +public class SpringDocApp101Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app102/InheritedRequestParams.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app102/InheritedRequestParams.java new file mode 100644 index 000000000..3f316795c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app102/InheritedRequestParams.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotBlank; + +import io.swagger.v3.oas.annotations.Parameter; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app102/RequestParams.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app102/RequestParams.java new file mode 100644 index 000000000..7ac58f856 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app102/RequestParams.java @@ -0,0 +1,146 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.lang.Nullable; + +public class RequestParams { + + @Parameter(description = "string parameter") + @JsonIgnore + 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app102/SpringDocApp102Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app102/SpringDocApp102Test.java new file mode 100644 index 000000000..9cd19f78a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app102/SpringDocApp102Test.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp102Test extends AbstractSpringDocV30Test { + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app102/TestController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app102/TestController.java new file mode 100644 index 000000000..bcdf60e69 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app102/TestController.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.api.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app103/ExampleBody.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app103/ExampleBody.java new file mode 100644 index 000000000..af704e4cd --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app103/ExampleBody.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class ExampleBody { + private String stringParam; + + private int intParam; + + 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; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app103/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app103/HelloController.java new file mode 100644 index 000000000..49ca72686 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app103/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app103/SpringDocApp103Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app103/SpringDocApp103Test.java new file mode 100644 index 000000000..4b863af1b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app103/SpringDocApp103Test.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp103Test extends AbstractSpringDocV30Test { + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/CrudController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/CrudController.java new file mode 100644 index 000000000..a13f8f5ce --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/CrudController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Controller +@SuppressWarnings("rawtypes") +public abstract class CrudController { + + @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; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/Design.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/Design.java new file mode 100644 index 000000000..990b140e9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/Design.java @@ -0,0 +1,26 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Design extends HavingPK { +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/DesignController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/DesignController.java new file mode 100644 index 000000000..3792dbe18 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/DesignController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Tag(name = "design") +@Controller +@RequestMapping("/design") +public class DesignController extends CrudController { + + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/HavingPK.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/HavingPK.java new file mode 100644 index 000000000..915178c44 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/HavingPK.java @@ -0,0 +1,26 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class HavingPK { +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/SpringDocApp104Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/SpringDocApp104Test.java new file mode 100644 index 000000000..0d6aee7f6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app104/SpringDocApp104Test.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp104Test extends AbstractSpringDocV30Test { + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/SpringDocApp105Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/SpringDocApp105Test.java new file mode 100644 index 000000000..138d5d34b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/SpringDocApp105Test.java @@ -0,0 +1,106 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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; + +@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", +}) +public class SpringDocApp105Test extends AbstractSpringDocV30Test { + + public static String className; + + @Test + public 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 + public 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 + public 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 + public 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)); + } + + + @SpringBootApplication + 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("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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/ApiUtil.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/ApiUtil.java new file mode 100644 index 000000000..8aa0f92fd --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/ApiUtil.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/ExceptionTranslator.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/ExceptionTranslator.java new file mode 100644 index 000000000..f71866443 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/ExceptionTranslator.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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("javax.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); + return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/HomeController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/HomeController.java new file mode 100644 index 000000000..9a4c3906c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/HomeController.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApi.java new file mode 100644 index 000000000..3d9b852b9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApi.java @@ -0,0 +1,164 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.NotNull; + +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 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; + +@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 { + + 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiController.java new file mode 100644 index 000000000..20658a267 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiDelegate.java new file mode 100644 index 000000000..c6ca24a49 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiDelegate.java @@ -0,0 +1,146 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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. + */ +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiDelegateImpl.java new file mode 100644 index 000000000..9435db92d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiDelegateImpl.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Service +public class PetApiDelegateImpl implements PetApiDelegate { + + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApi.java new file mode 100644 index 000000000..e81208072 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApi.java @@ -0,0 +1,109 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; + +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 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; + +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiController.java new file mode 100644 index 000000000..b52e1e717 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiDelegate.java new file mode 100644 index 000000000..efd4dd788 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiDelegate.java @@ -0,0 +1,97 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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. + */ +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiDelegateImpl.java new file mode 100644 index 000000000..252f6c070 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiDelegateImpl.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Service +public class StoreApiDelegateImpl implements StoreApiDelegate { + + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApi.java new file mode 100644 index 000000000..d86bfb534 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApi.java @@ -0,0 +1,137 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.NotNull; + +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 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; + +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiController.java new file mode 100644 index 000000000..61f913e30 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiDelegate.java new file mode 100644 index 000000000..e8a1bcc3e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiDelegate.java @@ -0,0 +1,126 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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. + */ +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiDelegateImpl.java new file mode 100644 index 000000000..8d7f724c6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiDelegateImpl.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Service +public class UserApiDelegateImpl implements UserApiDelegate { + + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Body.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Body.java new file mode 100644 index 000000000..bce45c84d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Body.java @@ -0,0 +1,101 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Body1.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Body1.java new file mode 100644 index 000000000..ac554d85b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Body1.java @@ -0,0 +1,103 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Category.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Category.java new file mode 100644 index 000000000..3996985a8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Category.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/ModelApiResponse.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/ModelApiResponse.java new file mode 100644 index 000000000..457272a63 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/ModelApiResponse.java @@ -0,0 +1,118 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Order.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Order.java new file mode 100644 index 000000000..cf3329f44 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Order.java @@ -0,0 +1,230 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Pet.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Pet.java new file mode 100644 index 000000000..fc23962a5 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Pet.java @@ -0,0 +1,245 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotNull; + +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 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Tag.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Tag.java new file mode 100644 index 000000000..cbfe23282 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/Tag.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/User.java new file mode 100644 index 000000000..b7ccee7ba --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app105/model/User.java @@ -0,0 +1,236 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app106/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app106/HelloController.java new file mode 100644 index 000000000..e691470e8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app106/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app106/SpringDocApp106Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app106/SpringDocApp106Test.java new file mode 100644 index 000000000..a94253bd9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app106/SpringDocApp106Test.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp106Test extends AbstractSpringDocV30Test { + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app107/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app107/HelloController.java new file mode 100644 index 000000000..1e4f57231 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app107/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping(path = "/entity-b", produces = { "application/json", "application/xml" }) + public EntityB getEntityB() { + return new EntityB(); + } + + public class EntityB { + + @Schema(required = true) + @JsonProperty("fieldB") + private String fieldB; + + @Schema(required = true) + @JsonProperty("entityA") + private EntityA entityA; + //Getters and setters... + } + + public class EntityA { + @Schema(required = true) + @JsonProperty("fieldA") + private String fieldA; + //Getters and setters... + } +} + diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app107/SpringDocApp107Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app107/SpringDocApp107Test.java new file mode 100644 index 000000000..89c796ba5 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app107/SpringDocApp107Test.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp107Test extends AbstractSpringDocV30Test { + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app108/ActionResult.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app108/ActionResult.java new file mode 100644 index 000000000..33b45680c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app108/ActionResult.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class ActionResult { + + protected T value; + + protected boolean success; + + protected String errorCode; + + protected String message; + + protected Object errorValue; + + protected String targetUrl; + + public T getValue() { + return value; + } + + public void setValue(T value) { + this.value = value; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Object getErrorValue() { + return errorValue; + } + + public void setErrorValue(Object errorValue) { + this.errorValue = errorValue; + } + + public String getTargetUrl() { + return targetUrl; + } + + public void setTargetUrl(String targetUrl) { + this.targetUrl = targetUrl; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app108/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app108/HelloController.java new file mode 100644 index 000000000..d4fe2aa9e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app108/HelloController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @PostMapping + public ActionResult update(String toto) { + return null; + } +} + diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app108/SpringDocApp108Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app108/SpringDocApp108Test.java new file mode 100644 index 000000000..df32fe636 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app108/SpringDocApp108Test.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp108Test extends AbstractSpringDocV30Test { + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app109/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app109/HelloController.java new file mode 100644 index 000000000..d82d319df --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app109/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping("/api/v1/resource") + public Resource getResource() { + return new ByteArrayResource(new 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app109/SpringDocApp109Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app109/SpringDocApp109Test.java new file mode 100644 index 000000000..b920a72a9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app109/SpringDocApp109Test.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp109Test extends AbstractSpringDocV30Test { + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app11/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app11/HelloController.java new file mode 100644 index 000000000..4910fa62a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app11/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @PostMapping(path = "/documents", consumes = "multipart/form-data") + public ResponseEntity uploadDocuments(@RequestPart("doc") List multipartFiles) { + return null; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java new file mode 100644 index 000000000..24a8663d9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp11Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/ErrorMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/ErrorMessage.java new file mode 100644 index 000000000..0feee2352 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/ErrorMessage.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +public class ErrorMessage { + + private List errors; + + public ErrorMessage() { + } + + public ErrorMessage(List errors) { + this.errors = errors; + } + + public ErrorMessage(String error) { + this(Collections.singletonList(error)); + } + + public ErrorMessage(String... errors) { + this(Arrays.asList(errors)); + } + + public List getErrors() { + return errors; + } + + public void setErrors(List errors) { + this.errors = errors; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/GlobalControllerAdvice.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/GlobalControllerAdvice.java new file mode 100644 index 000000000..5abf599be --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/GlobalControllerAdvice.java @@ -0,0 +1,153 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.ConstraintViolation; +import javax.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; + + +@ControllerAdvice(assignableTypes = PersonController.class) +public 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); + + @ExceptionHandler(Throwable.class) + @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity problem(final Throwable e) { + String message = e.getMessage(); + //might actually prefer to use a geeric mesasge + + 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); + } + + + @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); + } + + @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); + } + + @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); + } + + + @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); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/Person.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/Person.java new file mode 100644 index 000000000..f1c2d34f7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/Person.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.Email; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; + +import org.hibernate.validator.constraints.CreditCardNumber; + + +public class Person { + private long id; + + private String firstName; + + @NotNull + @NotBlank + @Size(max = 10) + private String lastName; + + @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") + private String email; + + @Email() + private String email1; + + @Min(18) + @Max(30) + private int age; + + @CreditCardNumber + private String creditCardNumber; + + public String getCreditCardNumber() { + return creditCardNumber; + } + + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getEmail1() { + return email1; + } + + public void setEmail1(String email1) { + this.email1 = email1; + } + + @Size(min = 2) + 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 getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/PersonController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/PersonController.java new file mode 100644 index 000000000..4193cfc2e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/PersonController.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.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; + +@RestController +@Validated +public class PersonController { + private Random ran = new Random(); + + @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; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/PersonController2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/PersonController2.java new file mode 100644 index 000000000..1bb1872d4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/PersonController2.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.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; + +@RestController +@Validated +public class PersonController2 { + private Random ran = new Random(); + + @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; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/Problem.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/Problem.java new file mode 100644 index 000000000..100a3b5c8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/Problem.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Problem { + + private String logRef; + + private String message; + + public Problem(String logRef, String message) { + super(); + this.logRef = logRef; + this.message = message; + } + + public Problem() { + super(); + + } + + public String getLogRef() { + return logRef; + } + + public void setLogRef(String logRef) { + this.logRef = logRef; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/SpringDocApp110Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/SpringDocApp110Test.java new file mode 100644 index 000000000..6da768b35 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app110/SpringDocApp110Test.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +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; + +@TestPropertySource(properties = { + "application-description=description", + "application-version=v1" }) +public class SpringDocApp110Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/ErrorMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/ErrorMessage.java new file mode 100644 index 000000000..08de34342 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/ErrorMessage.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +public class ErrorMessage { + + private List errors; + + public ErrorMessage() { + } + + public ErrorMessage(List errors) { + this.errors = errors; + } + + public ErrorMessage(String error) { + this(Collections.singletonList(error)); + } + + public ErrorMessage(String... errors) { + this(Arrays.asList(errors)); + } + + public List getErrors() { + return errors; + } + + public void setErrors(List errors) { + this.errors = errors; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/GlobalControllerAdvice.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/GlobalControllerAdvice.java new file mode 100644 index 000000000..13862acd9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/GlobalControllerAdvice.java @@ -0,0 +1,153 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.ConstraintViolation; +import javax.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; + + +@ControllerAdvice(basePackages = "test.org.springdoc.api.v30.appzzz") +public 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); + + @ExceptionHandler(Throwable.class) + @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity problem(final Throwable e) { + String message = e.getMessage(); + //might actually prefer to use a geeric mesasge + + 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); + } + + + @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); + } + + @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); + } + + @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); + } + + + @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); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/Person.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/Person.java new file mode 100644 index 000000000..ed2e726f0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/Person.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.Email; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; + +import org.hibernate.validator.constraints.CreditCardNumber; + + +public class Person { + private long id; + + private String firstName; + + @NotNull + @NotBlank + @Size(max = 10) + private String lastName; + + @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") + private String email; + + @Email() + private String email1; + + @Min(18) + @Max(30) + private int age; + + @CreditCardNumber + private String creditCardNumber; + + public String getCreditCardNumber() { + return creditCardNumber; + } + + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getEmail1() { + return email1; + } + + public void setEmail1(String email1) { + this.email1 = email1; + } + + @Size(min = 2) + 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 getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/PersonController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/PersonController.java new file mode 100644 index 000000000..bfba3930e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/PersonController.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.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; + +@RestController +@Validated +public class PersonController { + private Random ran = new Random(); + + @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; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/PersonController2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/PersonController2.java new file mode 100644 index 000000000..3278a62a1 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/PersonController2.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.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; + +@RestController +@Validated +public class PersonController2 { + private Random ran = new Random(); + + @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; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/Problem.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/Problem.java new file mode 100644 index 000000000..95a71f830 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/Problem.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Problem { + + private String logRef; + + private String message; + + public Problem(String logRef, String message) { + super(); + this.logRef = logRef; + this.message = message; + } + + public Problem() { + super(); + + } + + public String getLogRef() { + return logRef; + } + + public void setLogRef(String logRef) { + this.logRef = logRef; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/SpringDocApp111Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/SpringDocApp111Test.java new file mode 100644 index 000000000..865c5ffb3 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app111/SpringDocApp111Test.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +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; + +@TestPropertySource(properties = { + "application-description=description", + "application-version=v1" }) +public class SpringDocApp111Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/ErrorMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/ErrorMessage.java new file mode 100644 index 000000000..3b168b9c3 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/ErrorMessage.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +public class ErrorMessage { + + private List errors; + + public ErrorMessage() { + } + + public ErrorMessage(List errors) { + this.errors = errors; + } + + public ErrorMessage(String error) { + this(Collections.singletonList(error)); + } + + public ErrorMessage(String... errors) { + this(Arrays.asList(errors)); + } + + public List getErrors() { + return errors; + } + + public void setErrors(List errors) { + this.errors = errors; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/GlobalControllerAdvice.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/GlobalControllerAdvice.java new file mode 100644 index 000000000..78d906b25 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/GlobalControllerAdvice.java @@ -0,0 +1,153 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.ConstraintViolation; +import javax.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; + + +@ControllerAdvice(basePackages = "test.org.springdoc.api.v30.app112.sample") +public 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); + + @ExceptionHandler(Throwable.class) + @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity problem(final Throwable e) { + String message = e.getMessage(); + //might actually prefer to use a geeric mesasge + + 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); + } + + + @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); + } + + @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); + } + + @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); + } + + + @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); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/Person.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/Person.java new file mode 100644 index 000000000..a850e30c0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/Person.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.Email; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; + +import org.hibernate.validator.constraints.CreditCardNumber; + + +public class Person { + private long id; + + private String firstName; + + @NotNull + @NotBlank + @Size(max = 10) + private String lastName; + + @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") + private String email; + + @Email() + private String email1; + + @Min(18) + @Max(30) + private int age; + + @CreditCardNumber + private String creditCardNumber; + + public String getCreditCardNumber() { + return creditCardNumber; + } + + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getEmail1() { + return email1; + } + + public void setEmail1(String email1) { + this.email1 = email1; + } + + @Size(min = 2) + 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 getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/PersonController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/PersonController.java new file mode 100644 index 000000000..9b5685c88 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/PersonController.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.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; + +@RestController +@Validated +public class PersonController { + private Random ran = new Random(); + + @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; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/Problem.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/Problem.java new file mode 100644 index 000000000..7313d8ada --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/Problem.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Problem { + + private String logRef; + + private String message; + + public Problem(String logRef, String message) { + super(); + this.logRef = logRef; + this.message = message; + } + + public Problem() { + super(); + + } + + public String getLogRef() { + return logRef; + } + + public void setLogRef(String logRef) { + this.logRef = logRef; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/SpringDocApp112Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/SpringDocApp112Test.java new file mode 100644 index 000000000..a2cde84a2 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/SpringDocApp112Test.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +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; + +@TestPropertySource(properties = { + "application-description=description", + "application-version=v1" }) +public class SpringDocApp112Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/sample/PersonController2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/sample/PersonController2.java new file mode 100644 index 000000000..d6da662cf --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app112/sample/PersonController2.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import test.org.springdoc.api.v30.app112.Person; + +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; + +@RestController +@Validated +public class PersonController2 { + private Random ran = new Random(); + + @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; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app113/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app113/HelloController.java new file mode 100644 index 000000000..adefcf50f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app113/HelloController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @PostMapping("/lol") + public void test(@RequestBody(required = false) Body body) { + } + + @PostMapping("/lol2") + public void test2(@RequestBody Optional body) { + } + + public class Body { + public String field; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app113/SpringDocApp113Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app113/SpringDocApp113Test.java new file mode 100644 index 000000000..d2355bb5c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app113/SpringDocApp113Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +public class SpringDocApp113Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app114/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app114/HelloController.java new file mode 100644 index 000000000..af88ce42b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app114/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @PostMapping(value = "/foos1", consumes = MediaType.APPLICATION_JSON_VALUE) + MonetaryAmount getCurrency(@RequestBody CarDTO carDTO) { + return carDTO.price; + } + + class CarDTO { + @JsonProperty("price") + MonetaryAmount price; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app114/SpringDocApp114Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app114/SpringDocApp114Test.java new file mode 100644 index 000000000..339c7c8c4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app114/SpringDocApp114Test.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.SpringDocUtils; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +public class SpringDocApp114Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + static { + SpringDocUtils.getConfig().replaceWithClass(MonetaryAmount.class, org.springdoc.core.converters.models.MonetaryAmount.class); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app115/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app115/HelloController.java new file mode 100644 index 000000000..10c13a96d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app115/HelloController.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app115/JavaTimeOperationCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app115/JavaTimeOperationCustomizer.java new file mode 100644 index 000000000..db1af628f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app115/JavaTimeOperationCustomizer.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Component +public class JavaTimeOperationCustomizer implements OperationCustomizer { + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app115/SpringDocApp115Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app115/SpringDocApp115Test.java new file mode 100644 index 000000000..2c6850d8f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app115/SpringDocApp115Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +public class SpringDocApp115Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app116/FooErrorHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app116/FooErrorHandler.java new file mode 100644 index 000000000..e90180d7a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app116/FooErrorHandler.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@ControllerAdvice(assignableTypes = HelloController.class) +public class FooErrorHandler { + + @ExceptionHandler + public ResponseEntity storeAssignmentPublishingError(Exception e) { + return new ResponseEntity<>("foo", HttpStatus.INTERNAL_SERVER_ERROR); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app116/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app116/HelloController.java new file mode 100644 index 000000000..45d7f8788 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app116/HelloController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/api") +@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) +public class HelloController { + + @PostMapping("/foo") + public String create(@RequestBody String foo) { + return "foo"; + } +} + + diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app116/SpringDocApp116Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app116/SpringDocApp116Test.java new file mode 100644 index 000000000..764fb1e60 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app116/SpringDocApp116Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +public class SpringDocApp116Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app117/HelloApplication.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app117/HelloApplication.java new file mode 100644 index 000000000..2e00bdd51 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app117/HelloApplication.java @@ -0,0 +1,179 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.servlet.FilterChain; +import javax.servlet.GenericFilter; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +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.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; + +@Configuration +public class HelloApplication { + + @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(); + } +} + +@Component +class SimpleFilter extends GenericFilter { + + @Override + public void doFilter(ServletRequest req, ServletResponse res, + FilterChain filterChain) throws IOException, ServletException { + filterChain.doFilter(req, res); + } +} + +@Component +class PersonHandler { + + private final PersonService personService; + + PersonHandler(PersonService personService) { + this.personService = personService; + } + + ServerResponse handleGetAllPeople(ServerRequest serverRequest) { + return ok().body(personService.all()); + } + + 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); + } + + ServerResponse handleGetPersonById(ServerRequest r) { + return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); + } +} + +@RestController +class GreetingsRestController { + + @GetMapping("/greet/{name}") + String greet(@PathVariable String name) { + return "hello " + name + "!"; + } +} + +@Service +class PersonService { + + private final AtomicLong counter = new AtomicLong(); + + 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)); + + + Person save(Person p) { + Person person = new Person(counter.incrementAndGet(), p.getName()); + this.people.add(person); + return person; + } + + Set all() { + return this.people; + } + + 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!")); + } + +} + +class Person { + + public Person(Long id, String name) { + this.id = id; + this.name = name; + } + + 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; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app117/SpringDocApp117Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app117/SpringDocApp117Test.java new file mode 100644 index 000000000..aaa46ff4b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app117/SpringDocApp117Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +public class SpringDocApp117Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app118/AbstractParent.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app118/AbstractParent.java new file mode 100644 index 000000000..44184a228 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app118/AbstractParent.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@JsonTypeInfo(use = Id.NAME, property = "type") +@JsonSubTypes({ + @Type(ChildOfAbstract1.class), + @Type(ChildOfAbstract2.class) +}) +public abstract class AbstractParent { + private int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} + +class ChildOfAbstract1 extends AbstractParent { + private String abstrachChild1Param; + + public String getAbstrachChild1Param() { + return abstrachChild1Param; + } + + public void setAbstrachChild1Param(String abstrachChild1Param) { + this.abstrachChild1Param = abstrachChild1Param; + } +} + +class ChildOfAbstract2 extends AbstractParent { + private String abstractChild2Param; + + public String getAbstractChild2Param() { + return abstractChild2Param; + } + + public void setAbstractChild2Param(String abstractChild2Param) { + this.abstractChild2Param = abstractChild2Param; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app118/ConcreteParent.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app118/ConcreteParent.java new file mode 100644 index 000000000..5c6c8b5ec --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app118/ConcreteParent.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@JsonTypeInfo(use = Id.NAME, property = "type") +@JsonSubTypes({ + @Type(ChildOfConcrete1.class), + @Type(ChildOfConcrete2.class) +}) +public class ConcreteParent { + private int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} + +class ChildOfConcrete1 extends ConcreteParent { + private String concreteChild1Param; + + public String getConcreteChild1Param() { + return concreteChild1Param; + } + + public void setConcreteChild1Param(String concreteChild1Param) { + this.concreteChild1Param = concreteChild1Param; + } +} + +class ChildOfConcrete2 extends ConcreteParent { + private String concreteChild2Param; + + public String getConcreteChild2Param() { + return concreteChild2Param; + } + + public void setConcreteChild2Param(String concreteChild2Param) { + this.concreteChild2Param = concreteChild2Param; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app118/Controller.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app118/Controller.java new file mode 100644 index 000000000..73cad149e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app118/Controller.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("class-hierarchy") +public class Controller { + @PostMapping("abstract-parent") + public Response abstractParent(@RequestBody AbstractParent payload) { + return null; + } + + @PostMapping("concrete-parent") + public Response concreteParent(@RequestBody ConcreteParent payload) { + return null; + } +} + +class Response { + AbstractParent abstractParent; + + List concreteParents; + + public AbstractParent getAbstractParent() { + return abstractParent; + } + + public void setAbstractParent(AbstractParent abstractParent) { + this.abstractParent = abstractParent; + } + + public List getConcreteParents() { + return concreteParents; + } + + public void setConcreteParents(List concreteParents) { + this.concreteParents = concreteParents; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app118/SpringDocApp118Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app118/SpringDocApp118Test.java new file mode 100644 index 000000000..097f86a55 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app118/SpringDocApp118Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +public class SpringDocApp118Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java new file mode 100644 index 000000000..44665a1da --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app119/JsonRequest.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app119/JsonRequest.java new file mode 100644 index 000000000..fc99822fc --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app119/JsonRequest.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class JsonRequest { + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app119/SpringDocApp119Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app119/SpringDocApp119Test.java new file mode 100644 index 000000000..540a67066 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app119/SpringDocApp119Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +public class SpringDocApp119Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app12/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app12/HelloController.java new file mode 100644 index 000000000..c626c624d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app12/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app12/SpringDocApp12Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app12/SpringDocApp12Test.java new file mode 100644 index 000000000..0867ddc54 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app12/SpringDocApp12Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp12Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app120/AccountId.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app120/AccountId.java new file mode 100644 index 000000000..d62855bbd --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app120/AccountId.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Target({PARAMETER, METHOD, ANNOTATION_TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Parameter(description = "non alias description") +public @interface AccountId { + + @AliasFor(annotation = Parameter.class, value = "name") + String name() default ""; + + @AliasFor(annotation = Parameter.class, value = "example") + String example() default "123456"; + + @AliasFor(annotation = Parameter.class, value = "in") + ParameterIn in() default ParameterIn.DEFAULT; + + @AliasFor(annotation = Parameter.class, value = "schema") + Schema schema() default @Schema(); +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/MetaAnnotationController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app120/MetaAnnotationController.java similarity index 86% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/MetaAnnotationController.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app120/MetaAnnotationController.java index 835014cdc..23e1a51d2 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/MetaAnnotationController.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app120/MetaAnnotationController.java @@ -1,21 +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 + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; +package test.org.springdoc.api.v30.app120; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app120/SpringDocApp120Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app120/SpringDocApp120Test.java new file mode 100644 index 000000000..6fd9b9ad0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app120/SpringDocApp120Test.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +public class SpringDocApp120Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app121/InheritedRequestParams.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app121/InheritedRequestParams.java new file mode 100644 index 000000000..b6c59fb71 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app121/InheritedRequestParams.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotBlank; + +import io.swagger.v3.oas.annotations.Parameter; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app121/RequestParams.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app121/RequestParams.java new file mode 100644 index 000000000..9270cf787 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app121/RequestParams.java @@ -0,0 +1,141 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +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; + + 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; + } + + public String getIntParam3() { + return intParam3; + } + + public void setIntParam3(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-webmvc-core/src/test/java/test/org/springdoc/api/app121/SpringDocApp121Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app121/SpringDocApp121Test.java similarity index 79% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app121/SpringDocApp121Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app121/SpringDocApp121Test.java index 19bb95788..7295cc05f 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app121/SpringDocApp121Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app121/SpringDocApp121Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,11 +18,10 @@ * * * * * * - * */ -package test.org.springdoc.api.app121; +package test.org.springdoc.api.v30.app121; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -30,7 +29,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp121Test extends AbstractSpringDocTest { +public class SpringDocApp121Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app121/TestController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app121/TestController.java new file mode 100644 index 000000000..6f97c476f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app121/TestController.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.api.annotations.ParameterObject; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TestController { + + @PostMapping("test") + public InheritedRequestParams getTest(@RequestParam String param, @ParameterObject InheritedRequestParams requestParams) { + return requestParams; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/BaseController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/BaseController.java new file mode 100644 index 000000000..90bcffb0c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/BaseController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public abstract class BaseController { + + @PostMapping + @Operation(summary = "create") + public ResponseEntity create(@RequestBody Wrapper payload) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/BaseObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/BaseObject.java similarity index 88% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/BaseObject.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/BaseObject.java index 4ada247dd..8adf1030e 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/BaseObject.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/BaseObject.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,10 +18,9 @@ * * * * * * - * */ -package test.org.springdoc.api.app122; +package test.org.springdoc.api.v30.app122; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/CustomerDto.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/CustomerDto.java similarity index 89% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/CustomerDto.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/CustomerDto.java index a16317611..6f6b69bb4 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/CustomerDto.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/CustomerDto.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,10 +18,9 @@ * * * * * * - * */ -package test.org.springdoc.api.app122; +package test.org.springdoc.api.v30.app122; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/FirstController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/FirstController.java similarity index 89% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/FirstController.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/FirstController.java index eed9adedf..299934005 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/FirstController.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/FirstController.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,10 +18,9 @@ * * * * * * - * */ -package test.org.springdoc.api.app122; +package test.org.springdoc.api.v30.app122; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/SpringDocApp122Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/SpringDocApp122Test.java similarity index 79% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/SpringDocApp122Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/SpringDocApp122Test.java index 228d2e053..0a2ac8e7f 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/SpringDocApp122Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/SpringDocApp122Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,11 +18,10 @@ * * * * * * - * */ -package test.org.springdoc.api.app122; +package test.org.springdoc.api.v30.app122; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -30,7 +29,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp122Test extends AbstractSpringDocTest { +public class SpringDocApp122Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/Wrapper.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/Wrapper.java similarity index 88% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/Wrapper.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/Wrapper.java index c12d87049..0c8f136ca 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app122/Wrapper.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app122/Wrapper.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,10 +18,9 @@ * * * * * * - * */ -package test.org.springdoc.api.app122; +package test.org.springdoc.api.v30.app122; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app123/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app123/HelloController.java new file mode 100644 index 000000000..1e2d1d345 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app123/HelloController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app123/MyExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app123/MyExceptionHandler.java new file mode 100644 index 000000000..6adf73c8d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app123/MyExceptionHandler.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestControllerAdvice +public class MyExceptionHandler { + + @ExceptionHandler(IllegalArgumentException.class) + @ApiResponse(responseCode = "404", description = "Not here", content = @Content) + @ResponseStatus(HttpStatus.NOT_FOUND) + public void bad(IllegalArgumentException e) { + + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/app123/SpringDocApp123Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app123/SpringDocApp123Test.java similarity index 79% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app123/SpringDocApp123Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app123/SpringDocApp123Test.java index d6b6fb007..2e361c54f 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app123/SpringDocApp123Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app123/SpringDocApp123Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,11 +18,10 @@ * * * * * * - * */ -package test.org.springdoc.api.app123; +package test.org.springdoc.api.v30.app123; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -30,7 +29,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp123Test extends AbstractSpringDocTest { +public class SpringDocApp123Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app124/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app124/HelloController.java new file mode 100644 index 000000000..fe48c7970 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app124/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @ExceptionHandler(IllegalArgumentException.class) + @ApiResponse(responseCode = "404", description = "Not here", content = @Content) + @ResponseStatus(HttpStatus.NOT_FOUND) + public void bad(IllegalArgumentException e) { + + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app124/MyExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app124/MyExceptionHandler.java new file mode 100644 index 000000000..f1a7c3f41 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app124/MyExceptionHandler.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestControllerAdvice +public class MyExceptionHandler { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/app124/SpringDocApp124Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app124/SpringDocApp124Test.java similarity index 79% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app124/SpringDocApp124Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app124/SpringDocApp124Test.java index d178723a9..1bdb45e6b 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app124/SpringDocApp124Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app124/SpringDocApp124Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,11 +18,10 @@ * * * * * * - * */ -package test.org.springdoc.api.app124; +package test.org.springdoc.api.v30.app124; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -30,7 +29,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp124Test extends AbstractSpringDocTest { +public class SpringDocApp124Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app125/DeprecatedEntity.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app125/DeprecatedEntity.java new file mode 100644 index 000000000..d4cc47754 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app125/DeprecatedEntity.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +/** + * @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app125/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app125/HelloController.java new file mode 100644 index 000000000..0dc1a11c4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app125/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotNull; + +import org.springdoc.api.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-webmvc-core/src/test/java/test/org/springdoc/api/app125/SpringDocApp125Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app125/SpringDocApp125Test.java similarity index 87% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app125/SpringDocApp125Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app125/SpringDocApp125Test.java index 4f415b675..164ecc6b2 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app125/SpringDocApp125Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app125/SpringDocApp125Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,9 +18,8 @@ * * * * * * - * */ -package test.org.springdoc.api.app125; +package test.org.springdoc.api.v30.app125; import java.util.Optional; @@ -28,7 +27,7 @@ import io.swagger.v3.core.converter.ModelConverters; import org.junit.jupiter.api.BeforeAll; import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -38,7 +37,7 @@ * Tests Spring meta-annotations as method parameters */ @TestPropertySource(properties = "springdoc.model-converters.deprecating-converter.enabled=false") -public class SpringDocApp125Test extends AbstractSpringDocTest { +public class SpringDocApp125Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app126/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app126/HelloController.java new file mode 100644 index 000000000..60c836a30 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app126/HelloController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@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)}) }) +public class HelloController { + + private static final Collection CURRENCIES = new ArrayList<>(); + static { + CURRENCIES.add("EUR"); + CURRENCIES.add("USD"); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app126/Problem.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app126/Problem.java new file mode 100644 index 000000000..60cf7c9c0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app126/Problem.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public interface Problem { + + 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app126/SecurityProblemResponsesConfiguration.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app126/SecurityProblemResponsesConfiguration.java new file mode 100644 index 000000000..4b8287bfa --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app126/SecurityProblemResponsesConfiguration.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 +public class SecurityProblemResponsesConfiguration { + + private static final String HTTP_401_NO_TOKEN = "http401NoToken"; + private static final String HTTP_401_BAD_TOKEN = "http401BadToken"; + private static final String HTTP_403 = "http403"; + public static final String UNAUTHORIZED_401_NO_TOKEN_RESPONSE_REF = "#/components/responses/" + HTTP_401_NO_TOKEN; + public static final String UNAUTHORIZED_401_BAD_TOKEN_RESPONSE_REF = "#/components/responses/" + HTTP_401_BAD_TOKEN; + public static final String FORBIDDEN_403_RESPONSE_REF = "#/components/responses/" + HTTP_403; + + @Bean + public Map.Entry http401NoTokenResponse() throws IOException { + return simpleResponse(HTTP_401_NO_TOKEN, "Invalid authentication."); + } + + @Bean + public Map.Entry http401BadTokenResponse() throws IOException { + return simpleResponse(HTTP_401_BAD_TOKEN, "Invalid authentication."); + } + + @Bean + public Map.Entry http403Example() throws IOException { + return simpleResponse(HTTP_403, "Missing authorities."); + } + + 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-webmvc-core/src/test/java/test/org/springdoc/api/app126/SpringDocApp126Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app126/SpringDocApp126Test.java similarity index 88% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app126/SpringDocApp126Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app126/SpringDocApp126Test.java index 7eb1b364c..a88c15d39 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app126/SpringDocApp126Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app126/SpringDocApp126Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,9 +18,8 @@ * * * * * * - * */ -package test.org.springdoc.api.app126; +package test.org.springdoc.api.v30.app126; import java.util.List; import java.util.Map; @@ -30,7 +29,7 @@ import io.swagger.v3.core.converter.ResolvedSchema; import io.swagger.v3.oas.models.responses.ApiResponse; import org.springdoc.core.customizers.OpenApiCustomiser; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -39,7 +38,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp126Test extends AbstractSpringDocTest { +public class SpringDocApp126Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/AbstractObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/AbstractObject.java new file mode 100644 index 000000000..e4d14eeac --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/AbstractObject.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@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 { + + private final ConcreteType type; + private final String name; + + protected AbstractObject(ConcreteType type, String name) { + this.type = type; + this.name = name; + } + + public ConcreteType getType() { + return type; + } + + public String getName() { + return name; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/ConcreteObjectA.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/ConcreteObjectA.java new file mode 100644 index 000000000..2545878f2 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/ConcreteObjectA.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class ConcreteObjectA extends AbstractObject { + + private final String description; + + public ConcreteObjectA(String name, String description) { + super(ConcreteType.TYPE_A, name); + this.description = description; + } + + public String getDescription() { + return description; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/ConcreteType.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/ConcreteType.java new file mode 100644 index 000000000..6ce550d83 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/ConcreteType.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public enum ConcreteType { + TYPE_A("Type A"), + TYPE_B("Type B"); + + private final String name; + + ConcreteType(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/Controller.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/Controller.java new file mode 100644 index 000000000..dbba4dc92 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/Controller.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class Controller { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/app127/SpringDocApp127Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/SpringDocApp127Test.java similarity index 87% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/SpringDocApp127Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/SpringDocApp127Test.java index bb0463b77..f4830513b 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app127/SpringDocApp127Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/SpringDocApp127Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,14 +18,13 @@ * * * * * * - * */ -package test.org.springdoc.api.app127; +package test.org.springdoc.api.v30.app127; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springdoc.core.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.web.servlet.MvcResult; @@ -37,7 +36,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp127Test extends AbstractSpringDocTest { +public class SpringDocApp127Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/Umbrella.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/Umbrella.java new file mode 100644 index 000000000..fd5af155d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app127/Umbrella.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Umbrella { + + @Schema(description = "This reference to abstract class causes weird YAML tag to be added", anyOf = ConcreteObjectA.class) + private final AbstractObject object; + + public Umbrella(AbstractObject object) { + this.object = object; + } + + public AbstractObject getObject() { + return object; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app128/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app128/HelloController.java new file mode 100644 index 000000000..fbe4c488c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app128/HelloController.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/app128/SpringDocApp128Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app128/SpringDocApp128Test.java similarity index 90% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app128/SpringDocApp128Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app128/SpringDocApp128Test.java index 0df54d36e..c76f4b059 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app128/SpringDocApp128Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app128/SpringDocApp128Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,14 +18,13 @@ * * * * * * - * */ -package test.org.springdoc.api.app128; +package test.org.springdoc.api.v30.app128; import org.junit.jupiter.api.Test; import org.springdoc.core.Constants; import org.springdoc.core.SpringDocUtils; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController; @@ -44,7 +43,7 @@ @TestPropertySource(properties = { "springdoc.show-actuator=true", "management.endpoints.enabled-by-default=true", "management.endpoints.web.exposure.include = tenant" }) -public class SpringDocApp128Test extends AbstractSpringDocTest { +public class SpringDocApp128Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app129/ActualReturnedEntity.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app129/ActualReturnedEntity.java new file mode 100644 index 000000000..364627f97 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app129/ActualReturnedEntity.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class ActualReturnedEntity { + + @JsonProperty + String result; + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app129/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app129/HelloController.java new file mode 100644 index 000000000..75df72a66 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app129/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping(path = "/api", headers = {"userId", "registrationId"}) +public class HelloController { + + @PostMapping("/test") + @ApiResponses({@ApiResponse(responseCode = "200")}) + public DeferredResult> update( + @RequestBody ActualReturnedEntity entity) throws Exception { + return null; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app129/OperationResponse.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app129/OperationResponse.java new file mode 100644 index 000000000..fb68c41ab --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app129/OperationResponse.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class OperationResponse { + + @JsonProperty + String operationResult; +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app129/SpringDocApp129Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app129/SpringDocApp129Test.java similarity index 79% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app129/SpringDocApp129Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app129/SpringDocApp129Test.java index 77f7f46a2..82ed5a458 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app129/SpringDocApp129Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app129/SpringDocApp129Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,11 +18,10 @@ * * * * * * - * */ -package test.org.springdoc.api.app129; +package test.org.springdoc.api.v30.app129; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -30,7 +29,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp129Test extends AbstractSpringDocTest { +public class SpringDocApp129Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app13/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app13/HelloController.java new file mode 100644 index 000000000..71ba18ea6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app13/HelloController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping(value = "/persons") + public String persons(final PersonDTO dto) { + return "OK"; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app13/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app13/PersonDTO.java new file mode 100644 index 000000000..e0fee7875 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app13/PersonDTO.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app13/SpringDocApp13Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app13/SpringDocApp13Test.java new file mode 100644 index 000000000..898dbb9e9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app13/SpringDocApp13Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp13Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app130/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app130/HelloController.java new file mode 100644 index 000000000..c203d7398 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app130/HelloController.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @PostMapping(value = "/values/data") + TrackerData list(TrackerData toto) { + return toto; + } + + @GetMapping(value = "/values/datakk") + TrackerData get(TrackerData toto) { + return toto; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app130/SpringDocApp130Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app130/SpringDocApp130Test.java similarity index 79% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app130/SpringDocApp130Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app130/SpringDocApp130Test.java index b2a08d164..a63060303 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app130/SpringDocApp130Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app130/SpringDocApp130Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,11 +18,10 @@ * * * * * * - * */ -package test.org.springdoc.api.app130; +package test.org.springdoc.api.v30.app130; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -30,7 +29,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp130Test extends AbstractSpringDocTest { +public class SpringDocApp130Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app130/TrackerData.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app130/TrackerData.java new file mode 100644 index 000000000..f9b4bdd94 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app130/TrackerData.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Hidden +public class TrackerData { + + @JsonProperty("trackerId") + String trackerId; + + @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") + @JsonProperty("timestamp") + Instant timestamp; + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app131/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app131/HelloController.java new file mode 100644 index 000000000..bed758d76 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app131/HelloController.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app131/Organization.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app131/Organization.java new file mode 100644 index 000000000..dd69eff66 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app131/Organization.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Schema(description = + "This is the description being overwritten") +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"id", "name"}) +public class Organization { + + @Schema( + description = + "The Universally Unique Identifier (UUID) uniquely identifying the organization", + required = true) + @JsonProperty(required = true) + private UUID id; + + @Schema(description = "The name of the organization", required = true) + @JsonProperty(required = true) + private String name; + + public Organization() {} + + public UUID getId() { + return id; + } + + public String getName() { + return name; + } + + public void setId(UUID id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app131/RestControllerError.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app131/RestControllerError.java new file mode 100644 index 000000000..45788e38a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app131/RestControllerError.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class RestControllerError { + + @JsonProperty + private String id; + + @JsonProperty + private String message; + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app131/SpringDocApp131Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app131/SpringDocApp131Test.java similarity index 79% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app131/SpringDocApp131Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app131/SpringDocApp131Test.java index 6c507dea2..d7f0ed257 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app131/SpringDocApp131Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app131/SpringDocApp131Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,11 +18,10 @@ * * * * * * - * */ -package test.org.springdoc.api.app131; +package test.org.springdoc.api.v30.app131; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -30,7 +29,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp131Test extends AbstractSpringDocTest { +public class SpringDocApp131Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app132/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app132/HelloController.java new file mode 100644 index 000000000..fc5e46aaa --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app132/HelloController.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app132/Organization.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app132/Organization.java new file mode 100644 index 000000000..9a9bbee82 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app132/Organization.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Schema(description = + "This is the description being overwritten") +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"id", "name"}) +public class Organization { + + @Schema( + description = + "The Universally Unique Identifier (UUID) uniquely identifying the organization", + required = true) + @JsonProperty(required = true) + private UUID id; + + @Schema(description = "The name of the organization", required = true) + @JsonProperty(required = true) + private String name; + + public Organization() {} + + public UUID getId() { + return id; + } + + public String getName() { + return name; + } + + public void setId(UUID id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app132/RestControllerError.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app132/RestControllerError.java new file mode 100644 index 000000000..18e7195b0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app132/RestControllerError.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class RestControllerError { + + @JsonProperty + private String id; + + @JsonProperty + private String message; + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app132/SpringDocApp132Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app132/SpringDocApp132Test.java similarity index 79% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app132/SpringDocApp132Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app132/SpringDocApp132Test.java index a151eaa89..6f48171f1 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app132/SpringDocApp132Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app132/SpringDocApp132Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,11 +18,10 @@ * * * * * * - * */ -package test.org.springdoc.api.app132; +package test.org.springdoc.api.v30.app132; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -30,7 +29,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp132Test extends AbstractSpringDocTest { +public class SpringDocApp132Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app133/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app133/HelloController.java new file mode 100644 index 000000000..126499457 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app133/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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; + } + + @GetMapping("/test2") + public String getMessageFromHeader2( + @Parameter(name = "myHeader", description = "A header", schema = @Schema(type = "integer")) + @RequestHeader("myHeader") Integer header + ) { + return "bar " + header; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/app133/SpringDocApp133Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app133/SpringDocApp133Test.java similarity index 79% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app133/SpringDocApp133Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app133/SpringDocApp133Test.java index 4b219ae27..b4311ae70 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app133/SpringDocApp133Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app133/SpringDocApp133Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,11 +18,10 @@ * * * * * * - * */ -package test.org.springdoc.api.app133; +package test.org.springdoc.api.v30.app133; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -30,7 +29,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp133Test extends AbstractSpringDocTest { +public class SpringDocApp133Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app134/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app134/HelloController.java new file mode 100644 index 000000000..ac02181b3 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app134/HelloController.java @@ -0,0 +1,130 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +@SpringBootApplication +@RestController +@Tag(name = "The sample resource") +public class HelloController { + + // ----------------------------------------------------------------------------------------------------------------- + + public static final String VERSION_1 = "application/vnd.samples.v1+json"; + public static final String VERSION_2 = "application/vnd.samples.v2+json"; + public static final String HEADER_1 = "X-API-VERSION=1"; + public static final String HEADER_2 = "Accept-version=v2"; + + @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); + } + + @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); + } + + @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())); + } + + + private class SampleV1 { + + public String getId() { + return id; + } + + public SampleV1(String id) { + this.id = id; + } + + public void setId(String id) { + this.id = id; + } + + private String id; + } + + private class SampleV2 { + private long id; + + public SampleV2(long id) { + this.id = id; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + } + + private class SampleSearchRequest { + private final long id; + + public SampleSearchRequest(long id) { + this.id = id; + } + + public long getId() { + return id; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app134/OpenApiConfig.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app134/OpenApiConfig.java new file mode 100644 index 000000000..b292e404d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app134/OpenApiConfig.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class OpenApiConfig { + + @Bean + public GroupedOpenApi groupV1OpenApi() { + return GroupedOpenApi.builder() + .group("v1-group").producesToMatch(HelloController.VERSION_1) + .build(); + } + + @Bean + public GroupedOpenApi groupV2OpenApi() { + return GroupedOpenApi.builder() + .group("v2-group").producesToMatch(HelloController.VERSION_2) + .build(); + } + + @Bean + public GroupedOpenApi groupV3OpenApi() { + return GroupedOpenApi.builder() + .group("v2-consumes-group").consumesToMatch(HelloController.VERSION_2) + .build(); + } + + @Bean + public GroupedOpenApi groupV4OpenApi() { + return GroupedOpenApi.builder() + .group("v1-headers-group").headersToMatch(HelloController.HEADER_1) + .build(); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/app134/SpringDocApp134Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app134/SpringDocApp134Test.java similarity index 79% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app134/SpringDocApp134Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app134/SpringDocApp134Test.java index 9cce102bc..54241d806 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app134/SpringDocApp134Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app134/SpringDocApp134Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,13 +18,12 @@ * * * * * * - * */ -package test.org.springdoc.api.app134; +package test.org.springdoc.api.v30.app134; import org.junit.jupiter.api.Test; import org.springdoc.core.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -38,7 +37,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp134Test extends AbstractSpringDocTest { +public class SpringDocApp134Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} @@ -48,7 +47,7 @@ public 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)); + .andExpect(content().json(getContent("results/3.0.1/app134-1.json"), true)); } @Test @@ -56,7 +55,7 @@ public 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)); + .andExpect(content().json(getContent("results/3.0.1/app134-2.json"), true)); } @Test @@ -64,14 +63,14 @@ public 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)); + .andExpect(content().json(getContent("results/3.0.1/app134-3.json"), true)); } @Test public 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)); + .andExpect(content().json(getContent("results/3.0.1/app134-4.json"), true)); } @Test @@ -79,6 +78,6 @@ public 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)); + .andExpect(content().json(getContent("results/3.0.1/app134-5.json"), true)); } } diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app135/Book.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app135/Book.java new file mode 100644 index 000000000..3da7a9ba7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app135/Book.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app135/BookRepository.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app135/BookRepository.java new file mode 100644 index 000000000..9536a95ad --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app135/BookRepository.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Component +public class BookRepository { + + List findByAuthor(String author){ + Book[] books = {new Book("1", "title1","author1")}; + return Arrays.asList(books); + } + + List findAll() { + Book[] books = {new Book("2", "title2","author2")}; + return Arrays.asList(books); } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app135/BookRouter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app135/BookRouter.java new file mode 100644 index 000000000..36a49d3e4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app135/BookRouter.java @@ -0,0 +1,109 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@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 + 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"))))); + } + + @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"))))); + } + + @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"))))); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/app135/SpringDocApp135Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app135/SpringDocApp135Test.java similarity index 79% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app135/SpringDocApp135Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app135/SpringDocApp135Test.java index 561c8678f..59750065b 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app135/SpringDocApp135Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app135/SpringDocApp135Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,11 +18,10 @@ * * * * * * - * */ -package test.org.springdoc.api.app135; +package test.org.springdoc.api.v30.app135; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -30,7 +29,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp135Test extends AbstractSpringDocTest { +public class SpringDocApp135Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app136/OperationIdController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app136/OperationIdController.java new file mode 100644 index 000000000..b3a149b52 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app136/OperationIdController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app136; + +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 String opIdTest() { + return ""; + } + + @GetMapping(path = "/test_1") // gets operationId opIdTest_2 + public String opIdTest(@RequestParam String param) { + return ""; + } + + @GetMapping(path = "/test_2") // gets operationId opIdTest_1 + public String opIdTest(@RequestParam Integer param) { + return ""; + } + + @GetMapping(path = "/test_3") // gets operationId opIdTest + public String opIdTest(@RequestParam Boolean param) { + return ""; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app136/SpringDocApp136Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app136/SpringDocApp136Test.java similarity index 94% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app136/SpringDocApp136Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app136/SpringDocApp136Test.java index 8b08100f7..1c6e279a1 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app136/SpringDocApp136Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app136/SpringDocApp136Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,9 +18,8 @@ * * * * * * - * */ -package test.org.springdoc.api.app136; +package test.org.springdoc.api.v30.app136; import java.util.ArrayList; import java.util.Comparator; @@ -70,7 +69,7 @@ public void shouldGenerateOperationIdsDeterministically() throws Exception { HttpServletRequest request = mock(HttpServletRequest.class); when(request.getRequestURL()).thenReturn(new StringBuffer("http://localhost")); - String expected = getContent("results/app136.json"); + String expected = getContent("results/3.0.1/app136.json"); String openApi = resource.openapiJson(request, "", Locale.getDefault()); assertEquals(expected, openApi, true); } diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app137/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app137/HelloController.java new file mode 100644 index 000000000..2348c052a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app137/HelloController.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@SecurityRequirement(name = "security_auth") +public class HelloController { + + @GetMapping("/test") + public void test(String hello) { + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app137/OpenApiConfig.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app137/OpenApiConfig.java new file mode 100644 index 000000000..8d6a2c05e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app137/OpenApiConfig.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@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 = { }))) +public class OpenApiConfig {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app137/SpringDocApp137Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app137/SpringDocApp137Test.java similarity index 81% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app137/SpringDocApp137Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app137/SpringDocApp137Test.java index f2f3d6c9f..0a2c49483 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app137/SpringDocApp137Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app137/SpringDocApp137Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,11 +18,10 @@ * * * * * * - * */ -package test.org.springdoc.api.app137; +package test.org.springdoc.api.v30.app137; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -32,7 +31,7 @@ * Tests Spring meta-annotations as method parameters */ @TestPropertySource(properties = {"test.server=http://test.toto.com", "test.desc=toto desc"}) -public class SpringDocApp137Test extends AbstractSpringDocTest { +public class SpringDocApp137Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app138/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app138/HelloController.java new file mode 100644 index 000000000..45492da47 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app138/HelloController.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping("/testB") + public void testB(String hello) { + } + + @GetMapping("/testA") + public void testA(String hello) { + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app138/SpringDocApp138Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app138/SpringDocApp138Test.java similarity index 82% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app138/SpringDocApp138Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app138/SpringDocApp138Test.java index b9ae2d474..e00b4a243 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app138/SpringDocApp138Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app138/SpringDocApp138Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,9 +18,8 @@ * * * * * * - * */ -package test.org.springdoc.api.app138; +package test.org.springdoc.api.v30.app138; import java.lang.reflect.Field; import java.util.HashMap; @@ -28,7 +27,6 @@ import java.util.Map; import com.fasterxml.jackson.databind.ObjectMapper; -import io.swagger.v3.core.util.Json; import io.swagger.v3.core.util.ObjectMapperFactory; import io.swagger.v3.oas.models.OpenAPI; import org.apache.commons.lang3.reflect.FieldUtils; @@ -36,8 +34,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springdoc.core.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; +import org.springdoc.core.providers.ObjectMapperProvider; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.test.context.TestPropertySource; @@ -53,13 +53,16 @@ * Tests Spring meta-annotations as method parameters */ @TestPropertySource(properties = "springdoc.writer-with-order-by-keys=true") -public class SpringDocApp138Test extends AbstractSpringDocTest { +public class SpringDocApp138Test extends AbstractSpringDocV30Test { + + @Autowired + ObjectMapperProvider objectMapperProvider; @BeforeEach void init() throws IllegalAccessException { - Field conField = FieldUtils.getDeclaredField(Json.class, "mapper", true); + Field conField = FieldUtils.getDeclaredField(ObjectMapperProvider.class, "jsonMapper", true); ObjectMapper mapper = SpringDocObjectMapperFactory.createJson(); - conField.set(mapper, mapper); + conField.set(objectMapperProvider, mapper); } private static class SpringDocObjectMapperFactory extends ObjectMapperFactory { @@ -93,7 +96,7 @@ public void testApp() throws Exception { MvcResult mockMvcResult = mockMvc.perform(MockMvcRequestBuilders.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/app138.json"); + String expected = getContent("results/3.0.1/app138.json"); Assertions.assertEquals(expected, result); } diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app139/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app139/HelloController.java new file mode 100644 index 000000000..07d218e8f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app139/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test1") + public String echo1(@RequestParam(name = "${test.name}", defaultValue = "${test.default-value}") String text) { + return text; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/app139/SpringDocApp139Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app139/SpringDocApp139Test.java similarity index 82% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app139/SpringDocApp139Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app139/SpringDocApp139Test.java index 27b0ce68f..242f34a9b 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app139/SpringDocApp139Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app139/SpringDocApp139Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,11 +18,10 @@ * * * * * * - * */ -package test.org.springdoc.api.app139; +package test.org.springdoc.api.v30.app139; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -32,7 +31,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 AbstractSpringDocTest { +public class SpringDocApp139Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app14/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app14/HelloController.java new file mode 100644 index 000000000..a06f6fbdb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app14/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotBlank; + +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.HttpEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Tag(name = "greeting", description = "test") +public class HelloController { + + @GetMapping("/persons") + public void persons(@Valid @NotBlank String name) { + + } + + @GetMapping("/test") + @Tag(name = "lang.change") + public HttpEntity demo2() { + return null; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app14/SpringDocApp14Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app14/SpringDocApp14Test.java new file mode 100644 index 000000000..0a5c35e14 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app14/SpringDocApp14Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp14Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app140/HelloApplication.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app140/HelloApplication.java new file mode 100644 index 000000000..4403ebbda --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app140/HelloApplication.java @@ -0,0 +1,181 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.servlet.FilterChain; +import javax.servlet.GenericFilter; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +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.Constants.OPERATION_ATTRIBUTE; +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springframework.web.servlet.function.RouterFunctions.route; +import static org.springframework.web.servlet.function.ServerResponse.ok; + +@Configuration +public class HelloApplication { + + private static ServerResponse filter(ServerRequest serverRequest, HandlerFunction handlerFunction) throws Exception { + return handlerFunction.handle(serverRequest); + } + + @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(); + } +} + +@Component +class SimpleFilter extends GenericFilter { + + @Override + public void doFilter(ServletRequest req, ServletResponse res, + FilterChain filterChain) throws IOException, ServletException { + filterChain.doFilter(req, res); + } +} + +@Component +class PersonHandler { + + private final PersonService personService; + + PersonHandler(PersonService personService) { + this.personService = personService; + } + + ServerResponse handleGetAllPeople(ServerRequest serverRequest) { + return ok().body(personService.all()); + } + + 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); + } + + ServerResponse handleGetPersonById(ServerRequest r) { + return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); + } +} + +@RestController +class GreetingsRestController { + + @GetMapping("/greet/{name}") + String greet(@PathVariable String name) { + return "hello " + name + "!"; + } +} + +@Service +class PersonService { + + private final AtomicLong counter = new AtomicLong(); + + 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)); + + + Person save(Person p) { + Person person = new Person(counter.incrementAndGet(), p.getName()); + this.people.add(person); + return person; + } + + Set all() { + return this.people; + } + + 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!")); + } + +} + +class Person { + + public Person(Long id, String name) { + this.id = id; + this.name = name; + } + + 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; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app140/SpringDocApp140Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app140/SpringDocApp140Test.java similarity index 78% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app140/SpringDocApp140Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app140/SpringDocApp140Test.java index 38fac1290..a29da2e30 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app140/SpringDocApp140Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app140/SpringDocApp140Test.java @@ -1,9 +1,8 @@ /* - * * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -21,14 +20,14 @@ * */ -package test.org.springdoc.api.app140; +package test.org.springdoc.api.v30.app140; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp140Test extends AbstractSpringDocTest { +public class SpringDocApp140Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app141/Book.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app141/Book.java new file mode 100644 index 000000000..104ffd379 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app141/Book.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app141/BookRepository.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app141/BookRepository.java new file mode 100644 index 000000000..93eed28a4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app141/BookRepository.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Component +public class BookRepository { + + List findByAuthor(String author){ + Book[] books = {new Book("1", "title1","author1")}; + return Arrays.asList(books); + } + + List findAll() { + Book[] books = {new Book("2", "title2","author2")}; + return Arrays.asList(books); } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app141/BookRouter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app141/BookRouter.java new file mode 100644 index 000000000..3026b0dd8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app141/BookRouter.java @@ -0,0 +1,104 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants.OPERATION_ATTRIBUTE; +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +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; + +@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())) + .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"))) + ); + } + + @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")))); + } + + @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")))); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/app141/SpringDocApp141Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app141/SpringDocApp141Test.java similarity index 79% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app141/SpringDocApp141Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app141/SpringDocApp141Test.java index 8c2f4d002..9515e7bff 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app141/SpringDocApp141Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app141/SpringDocApp141Test.java @@ -1,9 +1,8 @@ /* - * * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -20,9 +19,9 @@ * * * */ -package test.org.springdoc.api.app141; +package test.org.springdoc.api.v30.app141; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -30,7 +29,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp141Test extends AbstractSpringDocTest { +public class SpringDocApp141Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app142/HelloApplication.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app142/HelloApplication.java new file mode 100644 index 000000000..75a3b004d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app142/HelloApplication.java @@ -0,0 +1,175 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.servlet.FilterChain; +import javax.servlet.GenericFilter; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +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.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.springframework.web.servlet.function.ServerResponse.ok; + +@Configuration +public class HelloApplication { + + private static ServerResponse filter(ServerRequest serverRequest, HandlerFunction handlerFunction) throws Exception { + return handlerFunction.handle(serverRequest); + } + + @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(); + } + +} + +@Component +class SimpleFilter extends GenericFilter { + + @Override + public void doFilter(ServletRequest req, ServletResponse res, + FilterChain filterChain) throws IOException, ServletException { + filterChain.doFilter(req, res); + } +} + +@Component +class PersonHandler { + + private final PersonService personService; + + PersonHandler(PersonService personService) { + this.personService = personService; + } + + ServerResponse handleGetAllPeople(ServerRequest serverRequest) { + return ok().body(personService.all()); + } + + 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); + } + + ServerResponse handleGetPersonById(ServerRequest r) { + return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); + } +} + +@RestController +class GreetingsRestController { + + @GetMapping("/greet/{name}") + String greet(@PathVariable String name) { + return "hello " + name + "!"; + } +} + +@Service +class PersonService { + + private final AtomicLong counter = new AtomicLong(); + + 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)); + + + Person save(Person p) { + Person person = new Person(counter.incrementAndGet(), p.getName()); + this.people.add(person); + return person; + } + + Set all() { + return this.people; + } + + 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!")); + } + +} + +class Person { + + public Person(Long id, String name) { + this.id = id; + this.name = name; + } + + 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; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app142/SpringDocApp142Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app142/SpringDocApp142Test.java similarity index 78% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app142/SpringDocApp142Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app142/SpringDocApp142Test.java index 51367b1c4..08e7aa335 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app142/SpringDocApp142Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app142/SpringDocApp142Test.java @@ -1,9 +1,8 @@ /* - * * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -21,14 +20,14 @@ * */ -package test.org.springdoc.api.app142; +package test.org.springdoc.api.v30.app142; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp142Test extends AbstractSpringDocTest { +public class SpringDocApp142Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app143/HelloHiddenController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app143/HelloHiddenController.java new file mode 100644 index 000000000..46edbf89f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app143/HelloHiddenController.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app143; + +import io.swagger.v3.oas.annotations.Hidden; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Hidden +public class HelloHiddenController { + + @GetMapping("/testA") + public void testA(String hello) { + } + + @GetMapping("/testB") + public void testB(String hello) { + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app143/SpringDocApp143Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app143/SpringDocApp143Test.java new file mode 100644 index 000000000..f66c6799d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app143/SpringDocApp143Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app143; + +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * Test issue 907 fix. + * Hidden controller showing up in swagger UI when springdoc.show-actuator is enabled + */ +@TestPropertySource(properties = {"management.endpoints.enabled-by-default=true", + "springdoc.show-actuator=true", "management.endpoints.web.exposure.exclude=functions" +}) +public class SpringDocApp143Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app144/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app144/HelloController.java new file mode 100644 index 000000000..35903c5f1 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app144/HelloController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app144/SpringDocApp144Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app144/SpringDocApp144Test.java new file mode 100644 index 000000000..1f9b93b65 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app144/SpringDocApp144Test.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorV30Test; + +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=55554", + "springdoc.use-management-port=true", + "management.server.port=9090", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp144Test extends AbstractSpringDocActuatorV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + @Test + public void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isNotFound()); + } + + @Test + public 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); + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app145/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app145/HelloController.java new file mode 100644 index 000000000..bab41fc9d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app145/HelloController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp145Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp145Test.java new file mode 100644 index 000000000..ea8001f88 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp145Test.java @@ -0,0 +1,97 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorV30Test; + +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=55556", + "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=9091", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp145Test extends AbstractSpringDocActuatorV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + @Test + public void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) + .andExpect(status().isNotFound()); + } + + @Test + public 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 + public 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 + public void testApp3() throws Exception { + try { + actuatorRestTemplate.getForObject("/application/openapi"+ "/"+Constants.DEFAULT_GROUP_NAME, String.class); + fail(); + } + catch (HttpStatusCodeException ex) { + // TODO: Currently obtain status 500 on MVC... Webflux obtain 404... + if (ex.getStatusCode() == HttpStatus.INTERNAL_SERVER_ERROR) + assertTrue(true); + else + fail(); + } + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app146/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app146/HelloController.java new file mode 100644 index 000000000..c03f7ce52 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app146/HelloController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app146/SpringDocApp146Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app146/SpringDocApp146Test.java new file mode 100644 index 000000000..1d6073c30 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app146/SpringDocApp146Test.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorV30Test; + +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=9099", + "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 SpringDocApp146Test extends AbstractSpringDocActuatorV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + + @Test + public 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/app146-1.json"), true)); + } + + @Test + public void testApp1() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/"+Constants.DEFAULT_GROUP_NAME)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app146-2.json"), true)); + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app147/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app147/HelloController.java new file mode 100644 index 000000000..f780a2ae8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app147/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app147/SpringDocApp147Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app147/SpringDocApp147Test.java new file mode 100644 index 000000000..a834ba4ff --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app147/SpringDocApp147Test.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorV30Test; + +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=9097", + "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 AbstractSpringDocActuatorV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + @Test + public 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 + public 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 + public void testApp2() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/"+Constants.DEFAULT_GROUP_NAME)) + .andExpect(status().isNotFound()); + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app148/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app148/HelloController.java new file mode 100644 index 000000000..a98b2722c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app148/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app148/SpringDocApp148Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app148/SpringDocApp148Test.java new file mode 100644 index 000000000..e31cc212b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app148/SpringDocApp148Test.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorV30Test; + +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; +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include:*", + "springdoc.show-actuator=true", + "management.server.port=9098", + "server.port=6666", + "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 AbstractSpringDocActuatorV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + + @Test + public void testApp() throws Exception { + String result = actuatorRestTemplate.getForObject("/test/application/openapi/users", String.class); + String expected = getContent("results/3.0.1/app148-1.json"); + assertEquals(expected, result, true); + } + + @Test + public void testApp2() throws Exception { + String result = actuatorRestTemplate.getForObject("/test/application/openapi/x-actuator", String.class); + String expected = getContent("results/3.0.1/app148-2.json"); + assertEquals(expected, result, true); + } + + @Test + public void testApp3() throws Exception { + try { + actuatorRestTemplate.getForObject("/test/application/openapi" + "/"+Constants.DEFAULT_GROUP_NAME, String.class); + fail(); + } + catch (HttpStatusCodeException ex) { + // TODO: Currently obtain status 500 on MVC... Webflux obtain 404... + if (ex.getStatusCode() == HttpStatus.INTERNAL_SERVER_ERROR) + assertTrue(true); + else + fail(); + } + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app149/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app149/HelloController.java new file mode 100644 index 000000000..43f813747 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app149/HelloController.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 +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 ModelAndView helloModelAndView() { + ModelAndView mav = new ModelAndView(); + mav.setViewName("forward:/message"); + return mav; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app149/HelloMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app149/HelloMessage.java new file mode 100644 index 000000000..c00621438 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app149/HelloMessage.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app149/HiddenHelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app149/HiddenHelloController.java new file mode 100644 index 000000000..e336de6b6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app149/HiddenHelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app149/SpringDocApp149Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app149/SpringDocApp149Test.java new file mode 100644 index 000000000..88009c560 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app149/SpringDocApp149Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.junit.jupiter.api.BeforeAll; +import org.springdoc.core.SpringDocUtils; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.model-and-view-allowed=true") +public class SpringDocApp149Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + @BeforeAll + public static void init() { + SpringDocUtils.getConfig().addHiddenRestControllers(HiddenHelloController.class); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app15/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app15/HelloController.java new file mode 100644 index 000000000..4cd59ca21 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app15/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app15/SpringDocApp15Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app15/SpringDocApp15Test.java new file mode 100644 index 000000000..4bd871db1 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app15/SpringDocApp15Test.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@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" +}) +public class SpringDocApp15Test extends AbstractSpringDocV30Test { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app150/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app150/HelloController.java new file mode 100644 index 000000000..edbdf76e0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app150/HelloController.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping("/test/") + @ApiResponse(responseCode = "204", description = "No content") + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void test(@RequestParam(defaultValue = "1") Integer 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) { + + } + + @GetMapping("/test3") + @ApiResponse(responseCode = "204", description = "No content") + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void test3(@RequestParam(defaultValue = "users,123") List toto) { + + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app150/SpringDocApp150Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app150/SpringDocApp150Test.java new file mode 100644 index 000000000..285edccff --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app150/SpringDocApp150Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +public class SpringDocApp150Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app151/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app151/HelloController.java new file mode 100644 index 000000000..28622d47d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app151/HelloController.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/test") +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app151/SpringDocApp151Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app151/SpringDocApp151Test.java new file mode 100644 index 000000000..50e53a1d4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app151/SpringDocApp151Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +public class SpringDocApp151Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app152/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app152/HelloController.java new file mode 100644 index 000000000..25e1d6974 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app152/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/api") +public class HelloController { + + @GetMapping + public String helloWorld() { + return "ok"; + } + + @Configuration + public class WebConfig implements WebMvcConfigurer { + + @Override + public void configurePathMatch(PathMatchConfigurer configurer) { + configurer.setPatternParser(new PathPatternParser()); + } + + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app152/SpringDocApp152Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app152/SpringDocApp152Test.java new file mode 100644 index 000000000..563358ec6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app152/SpringDocApp152Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +public class SpringDocApp152Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app153/OrderState.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app153/OrderState.java new file mode 100644 index 000000000..6fd0bc28d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app153/OrderState.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +@Schema(type="string", allowableValues={"finished", "new"}) +public enum OrderState { + FINISHED("finished"), + NEW("new"); + + OrderState(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + private final String value; +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app153/OrderStateMapper.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app153/OrderStateMapper.java new file mode 100644 index 000000000..a10b7251b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app153/OrderStateMapper.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class OrderStateMapper extends PropertyEditorSupport { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app153/SpringDocApp153Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app153/SpringDocApp153Test.java new file mode 100644 index 000000000..12cd3eb03 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app153/SpringDocApp153Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +public class SpringDocApp153Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app153/TestController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app153/TestController.java new file mode 100644 index 000000000..f9cc2af9e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app153/TestController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +class TestController { + + @InitBinder + public void initBinder(WebDataBinder dataBinder) { + dataBinder.registerCustomEditor(OrderState.class, new OrderStateMapper()); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app154/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app154/HelloController.java new file mode 100644 index 000000000..83adf4804 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app154/HelloController.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.api.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; + +@RestController +public class HelloController { + + + @GetMapping(path = "/") + public String hello() { + return "Hello world at " + Instant.now().toString(); + } + + @PostMapping(value = "/persons") + public void create(@ParameterObject Long id, @RequestBody Object o){ + + } + + @PostMapping(value = "/personsone") + public void createone(Long id, @RequestBody Object o){ + + } + + @PostMapping(value = "/createtwo") + public void createtwo(int id){ + + } + + @PostMapping(value = "/createthree") + public void createthree(Integer id){ + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app154/OpenApiConfiguration.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app154/OpenApiConfiguration.java new file mode 100644 index 000000000..8673e36fa --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app154/OpenApiConfiguration.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@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" + ) +}) +public class OpenApiConfiguration { +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app154/SpringDocApp154Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app154/SpringDocApp154Test.java new file mode 100644 index 000000000..149d8426b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app154/SpringDocApp154Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +public class SpringDocApp154Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/AbstractIntParameterObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/AbstractIntParameterObject.java new file mode 100644 index 000000000..d4af9325f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/AbstractIntParameterObject.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class AbstractIntParameterObject { + + int primitiveBaseField; + + T genericField; + + public int getPrimitiveBaseField() { + return primitiveBaseField; + } + + public void setPrimitiveBaseField(int primitiveBaseField) { + this.primitiveBaseField = primitiveBaseField; + } + + public T getGenericField() { + return genericField; + } + + public void setGenericField(T genericField) { + this.genericField = genericField; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/AbstractParameterObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/AbstractParameterObject.java new file mode 100644 index 000000000..186fd0fe5 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/AbstractParameterObject.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class AbstractParameterObject> { + + int primitiveBaseField; + + @Parameter(schema=@Schema(type = "string", allowableValues = {"ONE", "TWO"}) ) + T genericField; + + public int getPrimitiveBaseField() { + return primitiveBaseField; + } + + public void setPrimitiveBaseField(int primitiveBaseField) { + this.primitiveBaseField = primitiveBaseField; + } + + public T getGenericField() { + return genericField; + } + + public void setGenericField(T genericField) { + this.genericField = genericField; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/ConcreteEnum.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/ConcreteEnum.java new file mode 100644 index 000000000..bd2c3b51a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/ConcreteEnum.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + + +enum ConcreteEnum { + ONE, + TWO + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/ConcreteIntParameterObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/ConcreteIntParameterObject.java new file mode 100644 index 000000000..9511dd27e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/ConcreteIntParameterObject.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class ConcreteIntParameterObject extends AbstractIntParameterObject{ + + int primitiveConcreteField; + + public int getPrimitiveConcreteField() { + return primitiveConcreteField; + } + + public void setPrimitiveConcreteField(int primitiveConcreteField) { + this.primitiveConcreteField = primitiveConcreteField; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/ConcreteParameterObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/ConcreteParameterObject.java new file mode 100644 index 000000000..dfcce257b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/ConcreteParameterObject.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class ConcreteParameterObject extends AbstractParameterObject { + + int primitiveConcreteField; + + public int getPrimitiveConcreteField() { + return primitiveConcreteField; + } + + public void setPrimitiveConcreteField(int primitiveConcreteField) { + this.primitiveConcreteField = primitiveConcreteField; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/HelloController.java new file mode 100644 index 000000000..47957ba64 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.api.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 +public class HelloController { + + @GetMapping( "/test1") + public ResponseEntity sayHello( @ParameterObject final ConcreteParameterObject test) { + System.out.println("Field B = " + test); + return new ResponseEntity("{\"Say\": \"Hello\"}", HttpStatus.OK); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/SpringDocApp155Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/SpringDocApp155Test.java new file mode 100644 index 000000000..680c0cfdf --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app155/SpringDocApp155Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +public class SpringDocApp155Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app156/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app156/HelloController.java new file mode 100644 index 000000000..fbf19cccb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app156/HelloController.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app156/SomeEnum.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app156/SomeEnum.java new file mode 100644 index 000000000..f93851a63 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app156/SomeEnum.java @@ -0,0 +1,28 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public enum SomeEnum { + FIRST, + SECOND +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app156/SpringDocApp156Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app156/SpringDocApp156Test.java new file mode 100644 index 000000000..ba06980c8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app156/SpringDocApp156Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +public class SpringDocApp156Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app156/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app156/User.java new file mode 100644 index 000000000..0c66fe0de --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app156/User.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class User { + private String someText; + private Set textSet; + private Set someEnums; + + public String getSomeText() { + return someText; + } + + public void setSomeText(String someText) { + this.someText = someText; + } + + public Set getTextSet() { + return textSet; + } + + public void setTextSet(Set textSet) { + this.textSet = textSet; + } + + public Set getSomeEnums() { + return someEnums; + } + + public void setSomeEnums(Set someEnums) { + this.someEnums = someEnums; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/Bar.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/Bar.java new file mode 100644 index 000000000..6cc9ffdf6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/Bar.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 + */ +public class Bar { + private Object child; + + public Object getChild() { + return this.child; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/Foo.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/Foo.java new file mode 100644 index 000000000..f1d49451a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/Foo.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 + */ +public class Foo { + private String child; + + public String getChild() { + return this.child; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/HelloController.java new file mode 100644 index 000000000..ace57b777 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 +public class HelloController { + + @GetMapping( "/foo") + public ResponseEntity getFoo() { + return new ResponseEntity(HttpStatus.OK); + } + + @GetMapping( "/bar") + public ResponseEntity getBar() { + return new ResponseEntity(HttpStatus.OK); + } + + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/SpringDocApp157Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/SpringDocApp157Test.java new file mode 100644 index 000000000..cf43e8a0a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/SpringDocApp157Test.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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. + */ +public class SpringDocApp157Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringBootApp {} + + @Autowired + private StringyConverter stringyConverter; + + private ModelConverters converters = ModelConverters.getInstance(); + + @AfterEach + public void unregisterConverter() { + converters.removeConverter(stringyConverter); + } + + @Test + public 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")))); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/StringyConverter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/StringyConverter.java new file mode 100644 index 000000000..700435400 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app157/StringyConverter.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 +public 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/CommonFooErrorHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/CommonFooErrorHandler.java new file mode 100644 index 000000000..d11ba1632 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/CommonFooErrorHandler.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class CommonFooErrorHandler { + + @ExceptionHandler + @ResponseStatus(HttpStatus.CONFLICT) + public ErrorDTO onException(Exception e) { + return new ErrorDTO("Something wrong has happened"); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/ErrorDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/ErrorDTO.java new file mode 100644 index 000000000..6249bf1ca --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/ErrorDTO.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class ErrorDTO { + private String message; + + public ErrorDTO() { + } + + public ErrorDTO(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/HelloController.java new file mode 100644 index 000000000..438e03c00 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/HelloController.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/api") +@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) +public class HelloController { + + @GetMapping("/foo") + public SimpleDTO hello() { + return new SimpleDTO("foo"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/SimpleDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/SimpleDTO.java new file mode 100644 index 000000000..5e0b56f73 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/SimpleDTO.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class SimpleDTO { + + private String payload; + + public SimpleDTO() { + } + + public SimpleDTO(String payload) { + this.payload = payload; + } + + public String getPayload() { + return payload; + } + + public void setPayload(String payload) { + this.payload = payload; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/SpecificFooErrorHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/SpecificFooErrorHandler.java new file mode 100644 index 000000000..53a72e553 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/SpecificFooErrorHandler.java @@ -0,0 +1,29 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@ControllerAdvice(assignableTypes = HelloController.class) +public class SpecificFooErrorHandler extends CommonFooErrorHandler { +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/SpringDocApp158Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/SpringDocApp158Test.java new file mode 100644 index 000000000..a4d1e87e4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app158/SpringDocApp158Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp158Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/CustomException.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/CustomException.java new file mode 100644 index 000000000..bf5fe1329 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/CustomException.java @@ -0,0 +1,29 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class CustomException extends RuntimeException{ + public CustomException(String message) { + super(message); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/FooBean.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/FooBean.java new file mode 100644 index 000000000..c771fb284 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/FooBean.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class FooBean { + @JsonView(Views.View2.class) + private String message; + @JsonView(Views.View1.class) + private int code; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public FooBean(String message, int code) { + this.message = message; + this.code = code; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/FooErrorHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/FooErrorHandler.java new file mode 100644 index 000000000..ecd079e90 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/FooErrorHandler.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@ControllerAdvice(assignableTypes = HelloController.class) +public class FooErrorHandler { + + @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); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/HelloController.java new file mode 100644 index 000000000..5ed7e5da7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/api") +@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) +public class HelloController { + + @PostMapping("/foo") + public String create(@RequestBody String foo) { + return "foo"; + } +} + diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/SpringDocApp159Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/SpringDocApp159Test.java new file mode 100644 index 000000000..599361363 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/SpringDocApp159Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp159Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/Views.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/Views.java new file mode 100644 index 000000000..d70a7c963 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app159/Views.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Views { + public static class View1 { + } + public static class View2 extends View1 { + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app16/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app16/HelloController.java new file mode 100644 index 000000000..4f57ea5dc --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app16/HelloController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app16/SpringDocApp16Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app16/SpringDocApp16Test.java new file mode 100644 index 000000000..91f4cf5ec --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app16/SpringDocApp16Test.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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; + +@TestPropertySource(properties = "springdoc.api-docs.enabled=false") +public class SpringDocApp16Test extends AbstractSpringDocV30Test { + + @Test + public void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isNotFound()); + } + + @SpringBootConfiguration + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app160/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app160/HelloController.java new file mode 100644 index 000000000..ee81a9ffe --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app160/HelloController.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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; + +@RestController +public class HelloController { + + @PostMapping("test") + public ErrorResponse doSomethingInteresting() { + return null; + } + + @PropertySource("classpath:swagger-message-160.properties" ) + @Configuration + public class SwaggerMessage{} + + @Schema(description = "${ErrorResponse}") + public class ErrorResponse { + + @Schema(description = "${ErrorCode}", required = true) + @JsonProperty + private Integer errorCode; + + @Schema(description = "${ErrorMessage}") + @JsonProperty + private String errorMessage; + } + + @Bean + public GroupedOpenApi bundleApi() { + return GroupedOpenApi.builder() + .group("test") + .pathsToMatch("/**") + .build(); + } + + @Bean + public ResourceBundleMessageSource translator() { + ResourceBundleMessageSource source = new ResourceBundleMessageSource(); + source.setBasenames("swagger-message-160"); + source.setUseCodeAsDefaultMessage(true); + source.setDefaultEncoding("utf-8"); + return source; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app160/SpringDocApp160Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app160/SpringDocApp160Test.java new file mode 100644 index 000000000..dffdf96b9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app160/SpringDocApp160Test.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 org.junit.jupiter.api.Test; +import org.springdoc.core.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@TestPropertySource(properties = "springdoc.api-docs.resolve-schema-properties=true") +public class SpringDocApp160Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + } + + + @Test + public void testApp2() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/test")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app160-1.json"), true)); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app161/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app161/HelloController.java new file mode 100644 index 000000000..f80b4a895 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app161/HelloController.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + + @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; + } + + + @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; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app161/SpringDocApp161Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app161/SpringDocApp161Test.java new file mode 100644 index 000000000..b9428e544 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app161/SpringDocApp161Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 java.util.Locale; + +import org.junit.jupiter.api.Test; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp161Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + @Test + public void testApp() throws Exception { + Locale.setDefault(Locale.US); + super.testApp(); + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app162/OpenApiConfig.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app162/OpenApiConfig.java new file mode 100644 index 000000000..ef286ba1b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app162/OpenApiConfig.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 java.util.ArrayList; +import java.util.List; + +import io.swagger.v3.oas.models.servers.Server; +import org.springdoc.core.customizers.OpenApiCustomiser; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class OpenApiConfig { + @Bean + OpenApiCustomiser openApiCustomiser() { + return openApi -> { + openApi.getInfo().version("v1"); + Server server = new Server().url(""); + List servers=new ArrayList<>(); + servers.add(server); + openApi.servers(servers); + }; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app162/SpringDocApp162Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app162/SpringDocApp162Test.java new file mode 100644 index 000000000..8459ca152 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app162/SpringDocApp162Test.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 org.junit.jupiter.api.Test; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp162Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + @Test + public void testApp2() throws Exception { + super.testApp(); + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/CommissionDto.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/CommissionDto.java new file mode 100644 index 000000000..0d886abaa --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/CommissionDto.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.annotations.media.Schema; + +@Schema +public class CommissionDto { + private String email; + + private String firstName; + + private String lastName; + + public CommissionDto() { + } + + public CommissionDto(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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/CommissionsResource.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/CommissionsResource.java new file mode 100644 index 000000000..7ed081323 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/CommissionsResource.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; + +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.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.PathVariable; +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.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.http.ResponseEntity.accepted; + +@RestController +public class CommissionsResource { + + @PutMapping(value = "{id}", consumes = APPLICATION_JSON_VALUE) + @Operation(description = "updateCommission", summary = "Update a commission") + @ApiResponse(responseCode = "202", description = "Commission updated", content = @Content(schema = @Schema(implementation = CommissionDto.class), examples = @ExampleObject(name = "202", ref = Examples.PUT_COMMISSION_RESPONSE_BODY_EXAMPLE_KEY))) + public ResponseEntity updateCommission( + @Parameter(description = "Commission's id", required = true) @PathVariable("id") String commissionId, + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "A commission to update", required = true, content = @Content(schema = @Schema(implementation = CommissionDto.class), examples = @ExampleObject(name="requestExample", ref = Examples.PUT_COMMISSION_REQUEST_BODY_EXAMPLE_KEY))) @RequestBody(required = true) @Valid CommissionDto commission) { + return accepted().body(commission); + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/ExampleRegistrationCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/ExampleRegistrationCustomizer.java new file mode 100644 index 000000000..0f8ca3b53 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/ExampleRegistrationCustomizer.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 java.util.List; +import java.util.Map; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.examples.Example; +import org.springdoc.core.customizers.OpenApiCustomiser; + +import org.springframework.stereotype.Component; + +@Component +public class ExampleRegistrationCustomizer implements OpenApiCustomiser { + + private final List> examplesToRegister; + + public ExampleRegistrationCustomizer(List> examplesToRegister) { + this.examplesToRegister = examplesToRegister; + } + + @Override + public void customise(OpenAPI openApi) { + examplesToRegister.forEach(entry -> openApi.getComponents().addExamples(entry.getKey(), entry.getValue())); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/Examples.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/Examples.java similarity index 75% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/Examples.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/Examples.java index 356f8e822..68b034e65 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app163/Examples.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/Examples.java @@ -1,22 +1,26 @@ /* * - * * Copyright 2019-2020 the original author or authors. * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. * */ -package test.org.springdoc.api.app163; +package test.org.springdoc.api.v30.app163; import java.util.AbstractMap; import java.util.Map; diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/SpringDocApp163Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/SpringDocApp163Test.java new file mode 100644 index 000000000..5313a576c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app163/SpringDocApp163Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Import; + +public class SpringDocApp163Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + @Import({ Examples.class, ExampleRegistrationCustomizer.class }) + static class SpringDocTestApp { + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app164/SampleResponseClass.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app164/SampleResponseClass.java new file mode 100644 index 000000000..ecc647772 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app164/SampleResponseClass.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class SampleResponseClass { + + private String idAsFirstParameter; + + private String nameAsSecondParamater; + + private String lastNameAsThirdParameter; + + private boolean booleanValueAsFourthParameter; + + public String getIdAsFirstParameter() { + return idAsFirstParameter; + } + + public void setIdAsFirstParameter(String idAsFirstParameter) { + this.idAsFirstParameter = idAsFirstParameter; + } + + public String getNameAsSecondParamater() { + return nameAsSecondParamater; + } + + public void setNameAsSecondParamater(String nameAsSecondParamater) { + this.nameAsSecondParamater = nameAsSecondParamater; + } + + public String getLastNameAsThirdParameter() { + return lastNameAsThirdParameter; + } + + public void setLastNameAsThirdParameter(String lastNameAsThirdParameter) { + this.lastNameAsThirdParameter = lastNameAsThirdParameter; + } + + public boolean isBooleanValueAsFourthParameter() { + return booleanValueAsFourthParameter; + } + + public void setBooleanValueAsFourthParameter(boolean aBooleanValueAsFourthParameter) { + this.booleanValueAsFourthParameter = aBooleanValueAsFourthParameter; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app164/SpringDocApp164Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app164/SpringDocApp164Test.java new file mode 100644 index 000000000..9361e8269 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app164/SpringDocApp164Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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 AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app164/TestApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app164/TestApiController.java new file mode 100644 index 000000000..e2dddf6c2 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app164/TestApiController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TestApiController { + + @GetMapping(value = "/test") + public SampleResponseClass getInvoices() { + return null; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app165/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app165/HelloController.java new file mode 100644 index 000000000..f3c7cd009 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app165/HelloController.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app165; + +import java.util.List; + +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.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author bnasslahsen + */ +@RestController +@RequestMapping("/api") +public class HelloController { + + @Operation(description = "I want here some custom config") + @GetMapping("/sample1/{springdoc}") + public ResponseEntity sample1(@PathVariable(name = "#{T(org.springdoc.core.Constants).SPRINGDOC_PREFIX}") String id) { + throw new UnsupportedOperationException("the body is not relevant now"); + } + + @Operation(description = "I want here another some custom config") + @GetMapping("/sample2") + public ResponseEntity sample2(@RequestParam(defaultValue = "#{{}}") List value) { + throw new UnsupportedOperationException("the body is not relevant now"); + } + + @Operation(description = "I want here another some custom config") + @GetMapping("/sample3") + public ResponseEntity sample3(@RequestParam(defaultValue = "#{T(org.springdoc.core.Constants).DEFAULT_SWAGGER_UI_PATH}") String id) { + throw new UnsupportedOperationException("the body is not relevant now"); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app165/SpringDocApp165Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app165/SpringDocApp165Test.java new file mode 100644 index 000000000..bc1d0972d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app165/SpringDocApp165Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app165; + +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp165Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/GlobalErrorResponseDto.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/GlobalErrorResponseDto.java new file mode 100644 index 000000000..8b17e79f8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/GlobalErrorResponseDto.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class GlobalErrorResponseDto { + + private String globalMessage; + + public GlobalErrorResponseDto(String globalMessage) { + this.globalMessage = globalMessage; + } + + public String getGlobalMessage() { + return globalMessage; + } + + public void setGlobalMessage(String globalMessage) { + this.globalMessage = globalMessage; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/GlobalExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/GlobalExceptionHandler.java new file mode 100644 index 000000000..fdf3a27cb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/GlobalExceptionHandler.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +@Component("1") // bean name override to simulate order in HashMap +public class GlobalExceptionHandler { + + @ExceptionHandler(RuntimeException.class) + @ResponseStatus + public GlobalErrorResponseDto processException() { + return new GlobalErrorResponseDto("global"); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/LocalErrorResponseDto.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/LocalErrorResponseDto.java new file mode 100644 index 000000000..720ecabb6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/LocalErrorResponseDto.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class LocalErrorResponseDto { + + private String localMessage; + + public LocalErrorResponseDto(String localMessage) { + this.localMessage = localMessage; + } + + public String getLocalMessage() { + return localMessage; + } + + public void setLocalMessage(String localMessage) { + this.localMessage = localMessage; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/SpringDocApp166Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/SpringDocApp166Test.java new file mode 100644 index 000000000..5d8ae0efa --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/SpringDocApp166Test.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * In this test, it is checked that the error handler is displayed correctly in the documentation. + * Exactly, that the local handler takes precedence over the global one + * */ +@TestPropertySource(properties = "springdoc.api-docs.resolve-schema-properties=true") +public class SpringDocApp166Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/TestApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/TestApiController.java new file mode 100644 index 000000000..509847528 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app166/TestApiController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.springframework.stereotype.Component; +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 +@Component("0") // bean name override to simulate order in HashMap +public class TestApiController { + + @GetMapping(value = "/test") + public String throwError() { + throw new IllegalArgumentException(); + } + + @ExceptionHandler(RuntimeException.class) + @ResponseStatus + public LocalErrorResponseDto processException() { + return new LocalErrorResponseDto("local"); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app167/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app167/HelloController.java new file mode 100644 index 000000000..c3d1956b9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app167/HelloController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 io.swagger.v3.oas.annotations.Parameter; + +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 HelloController { + + @GetMapping("/sample1") + public ResponseEntity sample1(@Parameter(name="mySample") String mySample) { + throw new UnsupportedOperationException("the body is not relevant now"); + } + + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app167/SpringDocApp167Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app167/SpringDocApp167Test.java new file mode 100644 index 000000000..292a97ec9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app167/SpringDocApp167Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +@TestPropertySource(properties = "springdoc.disable-i18n=true") +public class SpringDocApp167Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app168/AbstractParent.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app168/AbstractParent.java new file mode 100644 index 000000000..b001eb6cb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app168/AbstractParent.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 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; + +@JsonTypeInfo(use = Id.NAME, property = "type") +@JsonSubTypes({ + @Type(ChildOfAbstract1.class), + @Type(ChildOfAbstract2.class) +}) +public abstract class AbstractParent { + private int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} + +class ChildOfAbstract1 extends AbstractParent { + private String abstrachChild1Param; + + public String getAbstrachChild1Param() { + return abstrachChild1Param; + } + + public void setAbstrachChild1Param(String abstrachChild1Param) { + this.abstrachChild1Param = abstrachChild1Param; + } +} + +class ChildOfAbstract2 extends AbstractParent { + private String abstractChild2Param; + + public String getAbstractChild2Param() { + return abstractChild2Param; + } + + public void setAbstractChild2Param(String abstractChild2Param) { + this.abstractChild2Param = abstractChild2Param; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app168/ConcreteParent.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app168/ConcreteParent.java new file mode 100644 index 000000000..9df5f9f51 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app168/ConcreteParent.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 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; + +@JsonTypeInfo(use = Id.NAME, property = "type") +@JsonSubTypes({ + @Type(ChildOfConcrete1.class), + @Type(ChildOfConcrete2.class) +}) +public class ConcreteParent { + private int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} + +class ChildOfConcrete1 extends ConcreteParent { + private String concreteChild1Param; + + public String getConcreteChild1Param() { + return concreteChild1Param; + } + + public void setConcreteChild1Param(String concreteChild1Param) { + this.concreteChild1Param = concreteChild1Param; + } +} + +class ChildOfConcrete2 extends ConcreteParent { + private String concreteChild2Param; + + public String getConcreteChild2Param() { + return concreteChild2Param; + } + + public void setConcreteChild2Param(String concreteChild2Param) { + this.concreteChild2Param = concreteChild2Param; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app168/Controller.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app168/Controller.java new file mode 100644 index 000000000..4037970a9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app168/Controller.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 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; + +@RestController +@RequestMapping("class-hierarchy") +public class Controller { + @PostMapping("abstract-parent") + public Response abstractParent(@RequestBody AbstractParent payload) { + return null; + } + + @PostMapping("concrete-parent") + public Response concreteParent(@RequestBody ConcreteParent payload) { + return null; + } +} + +class Response { + AbstractParent abstractParent; + + List concreteParents; + + public AbstractParent getAbstractParent() { + return abstractParent; + } + + public void setAbstractParent(AbstractParent abstractParent) { + this.abstractParent = abstractParent; + } + + public List getConcreteParents() { + return concreteParents; + } + + public void setConcreteParents(List concreteParents) { + this.concreteParents = concreteParents; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app168/SpringDocApp168Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app168/SpringDocApp168Test.java new file mode 100644 index 000000000..2fe9f76f5 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app168/SpringDocApp168Test.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.springdoc.core.Constants; +import org.springdoc.core.converters.PolymorphicModelConverter; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +@TestPropertySource(properties = Constants.SPRINGDOC_POLYMORPHIC_CONVERTER_ENABLED + "=false") +public class SpringDocApp168Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + static { + Optional modelConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof PolymorphicModelConverter).findAny(); + modelConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app169/DefaultRequestMappingHandlerMapping.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app169/DefaultRequestMappingHandlerMapping.java new file mode 100644 index 000000000..29bf76bb4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app169/DefaultRequestMappingHandlerMapping.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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.servlet.mvc.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app169/DefaultWebMvcRegistrations.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app169/DefaultWebMvcRegistrations.java new file mode 100644 index 000000000..fea5752df --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app169/DefaultWebMvcRegistrations.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; + +@Component +public class DefaultWebMvcRegistrations implements WebMvcRegistrations { + + @Override + public RequestMappingHandlerMapping getRequestMappingHandlerMapping() { + return new DefaultRequestMappingHandlerMapping(); + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app169/SpringDocApp169Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app169/SpringDocApp169Test.java new file mode 100644 index 000000000..45d19fc32 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app169/SpringDocApp169Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +public class SpringDocApp169Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app169/TestController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app169/TestController.java new file mode 100644 index 000000000..d0ebf3093 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app169/TestController.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app17/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app17/HelloController.java new file mode 100644 index 000000000..1cdd46e18 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app17/HelloController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.Size; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/persons") + public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) { + + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app17/SpringDocApp17Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app17/SpringDocApp17Test.java new file mode 100644 index 000000000..ed4676c43 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app17/SpringDocApp17Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp17Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app170/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app170/HelloController.java new file mode 100644 index 000000000..ec10dc741 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app170/HelloController.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + @GetMapping("hello") + public String hello() { + return "Hello"; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app170/SpringDocApp170Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app170/SpringDocApp170Test.java new file mode 100644 index 000000000..69008bad6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app170/SpringDocApp170Test.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 org.junit.jupiter.api.Test; +import org.springdoc.core.customizers.OpenApiCustomiser; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + + +public class SpringDocApp170Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + public OpenApiCustomiser openApiCustomiser() { + return openApi -> openApi.getServers().forEach(s -> s.url("URL")); + } + } + + @Test + public void testApp1() throws Exception { + this.testApp(); + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app171/HelloLocaleController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app171/HelloLocaleController.java new file mode 100644 index 000000000..e21b5dd38 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app171/HelloLocaleController.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotBlank; + +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.HttpEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Tag(name = "greeting", description = "test") +public class HelloLocaleController { + + @GetMapping("/persons") + public void persons(@Valid @NotBlank String name) { + } + + @GetMapping("/test") + public HttpEntity demo2() { + return null; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app171/SpringDocApp171Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app171/SpringDocApp171Test.java new file mode 100644 index 000000000..d5e00112d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app171/SpringDocApp171Test.java @@ -0,0 +1,82 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 java.util.Locale; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.Constants; +import org.springdoc.core.customizers.OpenApiLocaleCustomizer; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.support.ResourceBundleMessageSource; +import org.springframework.http.HttpHeaders; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.servlet.MvcResult; + +import static org.hamcrest.Matchers.is; +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@TestPropertySource(properties = Constants.SPRINGDOC_CACHE_DISABLED + "=false") +public class SpringDocApp171Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + + @Autowired + ResourceBundleMessageSource resourceBundleMessageSource; + + @Bean + public OpenApiLocaleCustomizer openApiLocaleCustomizer() { + return (openAPI, locale) + -> openAPI.getInfo().title(resourceBundleMessageSource.getMessage("test", null, locale)); + } + + } + + @Test + @Override + public void testApp() throws Exception { + Locale.setDefault(Locale.US); + testApp(Locale.US); + testApp(Locale.FRANCE); + testApp(Locale.UK); + } + + private void testApp(Locale locale) throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL).locale(locale).header(HttpHeaders.ACCEPT_LANGUAGE, locale.toLanguageTag())).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + String expected = getContent("results/3.0.1/app" + testNumber + "-" + locale.toLanguageTag() + ".json"); + assertEquals(expected, result, true); + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app172/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app172/HelloController.java new file mode 100644 index 000000000..4635ceaae --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app172/HelloController.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +@RestController +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app172/SpringDocApp172Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app172/SpringDocApp172Test.java new file mode 100644 index 000000000..8ffad4812 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app172/SpringDocApp172Test.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 org.junit.jupiter.api.Test; +import org.springdoc.core.Constants; +import org.springdoc.core.GroupedOpenApi; +import org.springdoc.core.customizers.OpenApiCustomiser; +import org.springdoc.core.customizers.OperationCustomizer; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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; + +@TestPropertySource(properties = { "springdoc.show-actuator=true", "management.endpoints.enabled-by-default=true", + "management.endpoints.web.exposure.include = tenant" }) +public class SpringDocApp172Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + public GroupedOpenApi actuatorApi(OpenApiCustomiser actuatorOpenApiCustomiser, OperationCustomizer actuatorCustomizer) { + return GroupedOpenApi.builder() + .group("sample-group") + .packagesToScan("test.org.springdoc.api.v30.app172") + .addOpenApiCustomiser(actuatorOpenApiCustomiser) + .addOperationCustomizer(actuatorCustomizer) + .pathsToExclude("/health/*") + .build(); + } + } + + @Test + public void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/sample-group")) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(status().isOk()) + .andExpect(content().json(getContent("results/3.0.1/app172.json"), true)); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app173/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app173/HelloController.java new file mode 100644 index 000000000..da86a7f6f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app173/HelloController.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 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"); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app173/SpringDocApp173Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app173/SpringDocApp173Test.java new file mode 100644 index 000000000..6102b918e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app173/SpringDocApp173Test.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Locale; + +import io.swagger.v3.oas.models.OpenAPI; +import org.junit.jupiter.api.Test; +import org.springdoc.core.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.http.HttpHeaders; +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; + +public class SpringDocApp173Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + public OpenAPI openAPI() { + return new OpenAPI(); + } + } + + @Test + @Override + public void testApp() throws Exception { + Locale.setDefault(Locale.US); + testApp(Locale.US); + testApp(Locale.FRANCE); + } + + private void testApp(Locale locale) throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL).locale(locale).header(HttpHeaders.ACCEPT_LANGUAGE, locale.toLanguageTag())).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + String expected = getContent("results/3.0.1/app" + testNumber +".json"); + assertEquals(expected, result, true); + } + + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app174/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app174/PersonDTO.java new file mode 100644 index 000000000..8d5d78772 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app174/PersonDTO.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app174/SpringDocApp174Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app174/SpringDocApp174Test.java new file mode 100644 index 000000000..1ef939428 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app174/SpringDocApp174Test.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 java.util.stream.Collectors; + +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.AbstractSpringDocV30Test; +import test.org.springdoc.api.v30.app175.PersonDTO; + +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.Import; +import org.springframework.web.bind.annotation.RequestMethod; + +@Import({ ReactorAutoConfiguration.class, FunctionExporterAutoConfiguration.class, ContextFunctionCatalogAutoConfiguration.class }) +public class SpringDocApp174Test extends AbstractSpringDocV30Test { + + @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).collect(Collectors.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app175/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app175/PersonDTO.java new file mode 100644 index 000000000..70467c927 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app175/PersonDTO.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/app175/SpringDocApp175Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app175/SpringDocApp175Test.java similarity index 76% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app175/SpringDocApp175Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app175/SpringDocApp175Test.java index c55acfd50..045f6d458 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app175/SpringDocApp175Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app175/SpringDocApp175Test.java @@ -1,22 +1,26 @@ /* * - * * Copyright 2019-2020 the original author or authors. * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; +package test.org.springdoc.api.v30.app175; import java.util.Arrays; import java.util.List; @@ -32,7 +36,7 @@ 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.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration; @@ -45,7 +49,7 @@ @Import({ ReactorAutoConfiguration.class, FunctionExporterAutoConfiguration.class, ContextFunctionCatalogAutoConfiguration.class }) @TestPropertySource(properties="springdoc.show-spring-cloud-functions=false") -public class SpringDocApp175Test extends AbstractSpringDocTest { +public class SpringDocApp175Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app176/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app176/HelloController.java new file mode 100644 index 000000000..b74114c5d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app176/HelloController.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app176; + +import java.util.List; + +import org.springdoc.api.annotations.ParameterObject; +import test.org.springdoc.api.v30.app13.PersonDTO; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app176/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app176/PersonDTO.java new file mode 100644 index 000000000..734c1fe03 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app176/PersonDTO.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app176; + +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-webmvc-core/src/test/java/test/org/springdoc/api/app176/SpringDocApp176Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app176/SpringDocApp176Test.java similarity index 78% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app176/SpringDocApp176Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app176/SpringDocApp176Test.java index 030fe42bf..00afdf599 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app176/SpringDocApp176Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app176/SpringDocApp176Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,16 +18,15 @@ * * * * * * - * */ -package test.org.springdoc.api.app176; +package test.org.springdoc.api.v30.app176; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp176Test extends AbstractSpringDocTest { +public class SpringDocApp176Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app177/AnnotatedController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app177/AnnotatedController.java new file mode 100644 index 000000000..213ee6eea --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app177/AnnotatedController.java @@ -0,0 +1,102 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app177; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import org.springdoc.core.GroupedOpenApi; +import org.springdoc.core.filters.OpenApiMethodFilter; + +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class AnnotatedController { + + @Group1 + @GetMapping("/annotated") + public String annotatedGet() { + return "annotated"; + } + + @Group1 + @Group3 + @PostMapping("/annotated") + public String annotatedPost() { + return "annotated"; + } + + @Group2 + @Group3 + @PutMapping("/annotated") + public String annotatedPut() { + return "annotated"; + } + + @PostMapping("/notAnnotated") + public String notAnnotatedPost() { + return "annotated"; + } + + @Bean + public GroupedOpenApi group1OpenApi() { + return GroupedOpenApi.builder() + .group("annotatedGroup1") + .addOpenApiMethodFilter(method -> method.isAnnotationPresent(Group1.class)) + .build(); + } + + @Bean + public GroupedOpenApi group2OpenApi() { + return GroupedOpenApi.builder() + .group("annotatedGroup2") + .addOpenApiMethodFilter(method -> method.isAnnotationPresent(Group2.class)) + .build(); + } + + @Bean + public GroupedOpenApi group3OpenApi() { + return GroupedOpenApi.builder() + .group("annotatedCombinedGroup") + .addOpenApiMethodFilter(method -> method.isAnnotationPresent(Group1.class) || method.isAnnotationPresent(Group2.class)) + .build(); + } + + @Bean + public OpenApiMethodFilter methodFilter(){ + return method -> method.isAnnotationPresent(Group3.class); + } + + @Retention(RetentionPolicy.RUNTIME) + @interface Group1 {} + + @Retention(RetentionPolicy.RUNTIME) + @interface Group2 {} + + @Retention(RetentionPolicy.RUNTIME) + @interface Group3 {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app177/SpringDocApp177Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app177/SpringDocApp177Test.java similarity index 81% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app177/SpringDocApp177Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app177/SpringDocApp177Test.java index d5c06d410..8365bc015 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app177/SpringDocApp177Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app177/SpringDocApp177Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,14 +18,13 @@ * * * * * * - * */ -package test.org.springdoc.api.app177; +package test.org.springdoc.api.v30.app177; import org.junit.jupiter.api.Test; import org.springdoc.core.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -35,7 +34,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -class SpringDocApp177Test extends AbstractSpringDocTest { +class SpringDocApp177Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} @@ -45,7 +44,7 @@ void testFilterOnlyPicksUpMatchedMethods() throws Exception { mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/annotatedGroup1")) .andExpect(status().isOk()) .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app177-1.json"), true)); + .andExpect(content().json(getContent("results/3.0.1/app177-1.json"), true)); } @Test @@ -53,7 +52,7 @@ void testFilterOnlyPicksUpMatchedMethodsWithDifferentFilter() throws Exception { mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/annotatedGroup2")) .andExpect(status().isOk()) .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app177-2.json"), true)); + .andExpect(content().json(getContent("results/3.0.1/app177-2.json"), true)); } @Test @@ -61,7 +60,7 @@ void testFilterOnlyPicksUpCombinedMatchedMethods() throws Exception { mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/annotatedCombinedGroup")) .andExpect(status().isOk()) .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app177-3.json"), true)); + .andExpect(content().json(getContent("results/3.0.1/app177-3.json"), true)); } } \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app178/AnnotatedController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app178/AnnotatedController.java new file mode 100644 index 000000000..354c4a9cf --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app178/AnnotatedController.java @@ -0,0 +1,101 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app178; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.util.function.Predicate; + +import org.springdoc.core.GroupedOpenApi; +import org.springdoc.core.customizers.OperationCustomizer; + +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class AnnotatedController { + + @Group1 + @GetMapping("/annotated") + public String annotatedGet() { + return "annotated"; + } + + @Group1 + @PostMapping("/annotated") + public String annotatedPost() { + return "annotated"; + } + + @Group2 + @PutMapping("/annotated") + public String annotatedPut() { + return "annotated"; + } + + + @Bean + public GroupedOpenApi group1OpenApi() { + Predicate hidingCondition = method -> method.isAnnotationPresent(Group1.class); + return GroupedOpenApi.builder() + .group("annotatedGroup1") + .addOperationCustomizer(getOperationCustomizer(hidingCondition)) + .build(); + } + + @Bean + public GroupedOpenApi group2OpenApi() { + Predicate filterCondition = method -> method.isAnnotationPresent(Group2.class); + return GroupedOpenApi.builder() + .group("annotatedGroup2") + .addOperationCustomizer(getOperationCustomizer(filterCondition)) + .build(); + } + + @Bean + public GroupedOpenApi group3OpenApi() { + Predicate hidingCondition = method -> method.isAnnotationPresent(Group1.class) || method.isAnnotationPresent(Group2.class); + return GroupedOpenApi.builder() + .group("annotatedCombinedGroup") + .addOperationCustomizer(getOperationCustomizer(hidingCondition)) + .build(); + } + + private OperationCustomizer getOperationCustomizer(Predicate filterCondition) { + return (operation, handlerMethod) -> filterCondition.test(handlerMethod.getMethod()) ? operation : null; + } + + @Retention(RetentionPolicy.RUNTIME) + @interface Group1 { + + } + + @Retention(RetentionPolicy.RUNTIME) + @interface Group2 { + + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app178/SpringDocApp178Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app178/SpringDocApp178Test.java similarity index 81% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app178/SpringDocApp178Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app178/SpringDocApp178Test.java index 54daa4526..bd6be22b9 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app178/SpringDocApp178Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app178/SpringDocApp178Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,14 +18,13 @@ * * * * * * - * */ -package test.org.springdoc.api.app178; +package test.org.springdoc.api.v30.app178; import org.junit.jupiter.api.Test; import org.springdoc.core.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -35,7 +34,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -class SpringDocApp178Test extends AbstractSpringDocTest { +class SpringDocApp178Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} @@ -45,7 +44,7 @@ void testFilterOnlyPicksUpMatchedMethods() throws Exception { mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/annotatedGroup1")) .andExpect(status().isOk()) .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app178-1.json"), true)); + .andExpect(content().json(getContent("results/3.0.1/app178-1.json"), true)); } @Test @@ -53,7 +52,7 @@ void testFilterOnlyPicksUpMatchedMethodsWithDifferentFilter() throws Exception { mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/annotatedGroup2")) .andExpect(status().isOk()) .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app178-2.json"), true)); + .andExpect(content().json(getContent("results/3.0.1/app178-2.json"), true)); } @Test @@ -61,7 +60,7 @@ void testFilterOnlyPicksUpCombinedMatchedMethods() throws Exception { mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/annotatedCombinedGroup")) .andExpect(status().isOk()) .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app178-3.json"), true)); + .andExpect(content().json(getContent("results/3.0.1/app178-3.json"), true)); } } \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/HelloController.java new file mode 100644 index 000000000..c4365e843 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/HelloController.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app179; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class HelloController { + @GetMapping("/test/{objId}") + String test(@MyIdPathVariable MyObj obj) { + return obj.getContent(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyConfiguration.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyConfiguration.java new file mode 100644 index 000000000..9e4a1c3dc --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyConfiguration.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app179; + +import java.util.List; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class MyConfiguration implements WebMvcConfigurer { + @Override + public void addArgumentResolvers(List resolvers) { + resolvers.add(new MyObjArgumentResolver()); + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyIdPathVariable.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyIdPathVariable.java new file mode 100644 index 000000000..493df9746 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyIdPathVariable.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app179; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.PARAMETER) +public @interface MyIdPathVariable { +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyObj.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyObj.java new file mode 100644 index 000000000..46c5012c9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyObj.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app179; + +public class MyObj { + private final String id; + private final String content; + + public MyObj(String id, String content) { + this.id = id; + this.content = content; + } + + public String getId() { + return id; + } + + public String getContent() { + return content; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyObjArgumentResolver.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyObjArgumentResolver.java new file mode 100644 index 000000000..a59105acf --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyObjArgumentResolver.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app179; + +import org.springframework.core.MethodParameter; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.ModelAndViewContainer; + + +public class MyObjArgumentResolver implements HandlerMethodArgumentResolver { + + @Override + public boolean supportsParameter(MethodParameter parameter) { + return parameter.hasParameterAnnotation(MyIdPathVariable.class) && + MyObj.class.isAssignableFrom(parameter.getParameterType()); + } + + @Override + public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, + NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { + return new MyObj("id", "content"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyPathParameterCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyPathParameterCustomizer.java new file mode 100644 index 000000000..d4ef0028e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/MyPathParameterCustomizer.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app179; + +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.parameters.Parameter; +import io.swagger.v3.oas.models.parameters.PathParameter; +import org.springdoc.core.customizers.ParameterCustomizer; + +import org.springframework.core.MethodParameter; +import org.springframework.stereotype.Component; + +@Component +public class MyPathParameterCustomizer implements ParameterCustomizer { + @Override + public Parameter customize(Parameter parameterModel, MethodParameter methodParameter) { + if (methodParameter.hasParameterAnnotation(MyIdPathVariable.class)) { + Parameter alternativeParameter = new PathParameter(); + alternativeParameter.setName("objId"); + alternativeParameter.setSchema(new StringSchema()); + return alternativeParameter; + } + return parameterModel; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/SpringDocApp179Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/SpringDocApp179Test.java new file mode 100644 index 000000000..fe6ef7f98 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app179/SpringDocApp179Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app179; + +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp179Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app18/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app18/HelloController.java new file mode 100644 index 000000000..e2d1d9a22 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app18/HelloController.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NegativeOrZero; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.PositiveOrZero; + +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; + +@RestController +public class HelloController { + + @GetMapping(value = "/persons") + public String persons(@NotBlank String name) { + return "OK"; + } + + @GetMapping(value = "/persons2") + public String persons2(@NotBlank @Parameter(description = "persons name") String name) { + return "OK"; + } + + @GetMapping(value = "/persons3") + public String persons3(@NotBlank @Parameter(description = "persons name") @RequestParam String name) { + return "OK"; + } + + @GetMapping(value = "/persons4") + public String persons4(@PositiveOrZero int age) { + return "OK"; + } + + @GetMapping(value = "/persons5") + public String persons5(@NegativeOrZero int age) { + return "OK"; + } + + @GetMapping(value = "/persons6") + public String persons6(@NotEmpty @Parameter(description = "persons name") String name) { + return "OK"; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app18/SpringDocApp18Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app18/SpringDocApp18Test.java new file mode 100644 index 000000000..f3a036b96 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app18/SpringDocApp18Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.pre-loading-enabled=true") +public class SpringDocApp18Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app180/Body.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app180/Body.java new file mode 100644 index 000000000..83e7d144c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app180/Body.java @@ -0,0 +1,105 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app180; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import io.swagger.v3.oas.annotations.media.Schema; + + +@Schema(name = "Body", description = "Body", example = "{\"key\":\"value\"}") +public class Body implements Map, MapExclusion { + + @Schema(hidden = true) + private Map data; + + public Map getData() { + return data; + } + + public void setData(Map data) { + this.data = data; + } + + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean containsKey(Object key) { + return false; + } + + @Override + public boolean containsValue(Object value) { + return false; + } + + @Override + public Object get(Object key) { + return null; + } + + @Override + public Object put(String key, Object value) { + return null; + } + + @Override + public Object remove(Object key) { + return null; + } + + @Override + public void putAll(Map m) { + + } + + @Override + public void clear() { + + } + + @Override + public Set keySet() { + return null; + } + + @Override + public Collection values() { + return null; + } + + @Override + public Set> entrySet() { + return null; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app180/MapExclusion.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app180/MapExclusion.java new file mode 100644 index 000000000..55c5349ad --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app180/MapExclusion.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app180; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +public interface MapExclusion { + @JsonIgnore + boolean isEmpty(); +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app180/RESTService.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app180/RESTService.java new file mode 100644 index 000000000..481db8f16 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app180/RESTService.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app180; + +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.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; + +@RestController +@RequestMapping("api") +@Tag(name = "REST Service") +public class RESTService { + + @PostMapping("/testWithoutSchema") + @Operation(summary = "Test Request Body type Schema usage [Error]") + public String withoutSchema(@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true) + @RequestBody Body body) { + return "without proper schema"; + } + + @PostMapping("/testWithSchema") + @Operation(summary = "Test Request Body type Schema usage [Correct]") + public String withSchema(@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = @Content(schema = @Schema(implementation = Body.class))) + @RequestBody Body body) { + return "with proper schema"; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app180/SpringDocApp180Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app180/SpringDocApp180Test.java similarity index 78% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app180/SpringDocApp180Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app180/SpringDocApp180Test.java index b6c90f243..34417247e 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app180/SpringDocApp180Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app180/SpringDocApp180Test.java @@ -2,7 +2,7 @@ * * * * * * - * * * * Copyright 2019-2020 the original author or authors. + * * * * Copyright 2019-2022 the original author or authors. * * * * * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * * * you may not use this file except in compliance with the License. @@ -18,16 +18,15 @@ * * * * * * - * */ -package test.org.springdoc.api.app180; +package test.org.springdoc.api.v30.app180; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; -class SpringDocApp180Test extends AbstractSpringDocTest { +class SpringDocApp180Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app181/AbstractParameterObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app181/AbstractParameterObject.java new file mode 100644 index 000000000..9005f4ec0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app181/AbstractParameterObject.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app181; + +public class AbstractParameterObject { + + int primitiveBaseField; + + T genericField; + + public int getPrimitiveBaseField() { + return primitiveBaseField; + } + + public void setPrimitiveBaseField(int primitiveBaseField) { + this.primitiveBaseField = primitiveBaseField; + } + + public T getGenericField() { + return genericField; + } + + public void setGenericField(T genericField) { + this.genericField = genericField; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app181/ConcreteParameterObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app181/ConcreteParameterObject.java new file mode 100644 index 000000000..7a803f3f1 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app181/ConcreteParameterObject.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app181; + +public class ConcreteParameterObject extends AbstractParameterObject { + + int primitiveConcreteField; + + public int getPrimitiveConcreteField() { + return primitiveConcreteField; + } + + public void setPrimitiveConcreteField(int primitiveConcreteField) { + this.primitiveConcreteField = primitiveConcreteField; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app181/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app181/HelloController.java new file mode 100644 index 000000000..b27501354 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app181/HelloController.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app181; + +import org.springdoc.api.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 +public class HelloController { + + @GetMapping( "/test1") + public ResponseEntity sayHello( @ParameterObject final ConcreteParameterObject 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app181/SpringDocApp181Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app181/SpringDocApp181Test.java new file mode 100644 index 000000000..6dbd88f33 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app181/SpringDocApp181Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app181; + + +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +public class SpringDocApp181Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app182/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app182/HelloController.java new file mode 100644 index 000000000..ec4e97462 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app182/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app182; + +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; + +@RestController +public class HelloController { + + @ExceptionHandler(IllegalArgumentException.class) + @ApiResponse(responseCode = "404", description = "Not here", content = @Content) + @ResponseStatus(HttpStatus.NOT_FOUND) + public void bad(IllegalArgumentException e) { + + } + + @ExceptionHandler(RuntimeException.class) + @ResponseStatus(HttpStatus.BAD_GATEWAY) + public Object gateway(RuntimeException e) { + return null; + } + + @GetMapping(value = "/hello/{numTelco}") + @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) + public T index(@PathVariable("numTelco") String numTel, String adresse) { + throw new IllegalArgumentException(); + + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app182/SpringDocApp182Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app182/SpringDocApp182Test.java new file mode 100644 index 000000000..9323f6542 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app182/SpringDocApp182Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app182; + +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Copy of 124 without RestControllerAdvice class + */ +public class SpringDocApp182Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/HelloController.java new file mode 100644 index 000000000..beeec57ae --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app183; + +import io.swagger.v3.oas.annotations.tags.Tag; + +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 +@Tag(name = "NetworkServices", description = "the NetworkServices API") +public class HelloController { + + + + + @GetMapping("/{userId}") + public User doSomething(@PathVariable("userId") User user) { + return new User(user.getId(), "tototot"); + } + + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/SpringDocApp183Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/SpringDocApp183Test.java new file mode 100644 index 000000000..930158567 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/SpringDocApp183Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app183; + +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp183Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/User.java new file mode 100644 index 000000000..079593d17 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/User.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app183; + +public class User { + + String id; + + String toto; + + + public User() { + } + + public User(String id, String toto) { + this.id = id; + this.toto = toto; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getToto() { + return toto; + } + + public void setToto(String toto) { + this.toto = toto; + } + + @Override + public String toString() { + return "User{" + + "id='" + id + '\'' + + ", toto='" + toto + '\'' + + '}'; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/UserConverter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/UserConverter.java new file mode 100644 index 000000000..412fa858c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/UserConverter.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app183; + +import org.springframework.core.convert.converter.Converter; + +public class UserConverter implements Converter { + + @Override + public User convert(String userId) { + // Fetch from repository + User user = new User(); + user.setId(userId); + return user; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/WebConfig.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/WebConfig.java new file mode 100644 index 000000000..5363e81eb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app183/WebConfig.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app183; + +import org.springframework.context.annotation.Configuration; +import org.springframework.format.FormatterRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebConfig implements WebMvcConfigurer { + + @Override + public void addFormatters(FormatterRegistry registry) { + registry.addConverter(new UserConverter()); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app184/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app184/HelloController.java new file mode 100644 index 000000000..f67702a0f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app184/HelloController.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/app184/SpringDocApp184Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app184/SpringDocApp184Test.java similarity index 75% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app184/SpringDocApp184Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app184/SpringDocApp184Test.java index 0391e7680..1e84b4b99 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app184/SpringDocApp184Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app184/SpringDocApp184Test.java @@ -1,22 +1,26 @@ /* * - * * Copyright 2019-2020 the original author or authors. * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; +package test.org.springdoc.api.v30.app184; import java.util.Objects; @@ -31,7 +35,7 @@ import org.springdoc.core.customizers.OperationCustomizer; import org.springdoc.core.filters.GlobalOpenApiMethodFilter; import org.springdoc.core.filters.OpenApiMethodFilter; -import test.org.springdoc.api.AbstractSpringDocTest; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -45,7 +49,7 @@ "springdoc.group-configs[0].group=group1", "springdoc.group-configs[0].paths-to-exclude=/group1Filtered", }) -public class SpringDocApp184Test extends AbstractSpringDocTest { +public class SpringDocApp184Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp { @@ -106,21 +110,21 @@ public GroupedOpenApi group3() { public void testGroup1() throws Exception { mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/group1")) .andExpect(status().isOk()) - .andExpect(content().json(getContent("results/app184-1.json"), true)); + .andExpect(content().json(getContent("results/3.0.1/app184-1.json"), true)); } @Test public void testGroup2() throws Exception { mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/group2")) .andExpect(status().isOk()) - .andExpect(content().json(getContent("results/app184-2.json"), true)); + .andExpect(content().json(getContent("results/3.0.1/app184-2.json"), true)); } @Test public void testGroup3() throws Exception { mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/group3")) .andExpect(status().isOk()) - .andExpect(content().json(getContent("results/app184-3.json"), true)); + .andExpect(content().json(getContent("results/3.0.1/app184-3.json"), true)); } } \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/Cat.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/Cat.java new file mode 100644 index 000000000..4afee62d0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/Cat.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app185; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class Cat extends Pet { + + private final boolean meows; + + public Cat() { + super(); + this.meows = false; + } + + public Cat(boolean meows, String name) { + super(name); + this.meows = meows; + } + + public boolean getMeows() { + return meows; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/Dog.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/Dog.java new file mode 100644 index 000000000..ae6405c3d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/Dog.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app185; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class Dog extends Pet { + + private final boolean barks; + + public Dog() { + super(); + this.barks = false; + } + + public Dog(boolean barks, String name) { + super(name); + this.barks = barks; + } + + public boolean getBarks() { + return barks; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/Pet.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/Pet.java new file mode 100644 index 000000000..92ac92ed9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/Pet.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app185; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") +@JsonSubTypes({ + @JsonSubTypes.Type(Dog.class), + @JsonSubTypes.Type(Cat.class) +}) +public class Pet { + + public final String name; + + public Pet() { + this.name = null; + } + + public Pet(String name) { + this.name = name; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/PetController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/PetController.java new file mode 100644 index 000000000..5ef6f09aa --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/PetController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app185; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class PetController { + + @GetMapping("/any") + public Pet getAnyPet() { + return new Cat(true, "cat"); + } + + @GetMapping("/dog") + public Dog getDog() { + return new Dog(true, "dog"); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/SpringDocApp185Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/SpringDocApp185Test.java new file mode 100644 index 000000000..e8def0dd9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app185/SpringDocApp185Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app185; + +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp185Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app19/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app19/HelloController.java new file mode 100644 index 000000000..5179bd62a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app19/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotBlank; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @PostMapping(value = "/persons") + public String persons(@RequestBody(description = "requestBody description as parameter") String name) { + return "OK"; + } + + @RequestBody(description = "requestBody description outside") + @PostMapping(value = "/persons2") + public String persons2(String name) { + return "OK"; + } + + @Operation(requestBody = @RequestBody(description = "requestBody inside operation annotation")) + @PostMapping(value = "/persons3") + public String persons3(@NotBlank String name) { + return "OK"; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app19/SpringDocApp19Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app19/SpringDocApp19Test.java new file mode 100644 index 000000000..dd18bd5e1 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app19/SpringDocApp19Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp19Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java new file mode 100644 index 000000000..4db6da0b8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp2Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + 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("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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/ApiUtil.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/ApiUtil.java new file mode 100644 index 000000000..b924fb897 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/ApiUtil.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/ExceptionTranslator.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/ExceptionTranslator.java new file mode 100644 index 000000000..49cf227f5 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/ExceptionTranslator.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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("javax.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); + return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/HomeController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/HomeController.java new file mode 100644 index 000000000..2463dfbe3 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/HomeController.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/PetApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/PetApi.java new file mode 100644 index 000000000..cdf22bb0a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/PetApi.java @@ -0,0 +1,166 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.NotNull; + +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 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; + +@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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiController.java new file mode 100644 index 000000000..043eb04ea --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@javax.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:/}") +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiDelegate.java new file mode 100644 index 000000000..1c9dc8635 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiDelegate.java @@ -0,0 +1,145 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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. + */ +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiDelegateImpl.java new file mode 100644 index 000000000..dac691629 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiDelegateImpl.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Service +public class PetApiDelegateImpl implements PetApiDelegate { + + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApi.java new file mode 100644 index 000000000..849149dfa --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApi.java @@ -0,0 +1,109 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +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 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; + +@javax.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}") + @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); + } + + @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(); + } + + @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); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiController.java new file mode 100644 index 000000000..f8d7ce0c9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@javax.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:/}") +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiDelegate.java new file mode 100644 index 000000000..76df2ca00 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiDelegate.java @@ -0,0 +1,96 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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. + */ +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiDelegateImpl.java new file mode 100644 index 000000000..b2e871a77 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiDelegateImpl.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Service +public class StoreApiDelegateImpl implements StoreApiDelegate { + + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/UserApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/UserApi.java new file mode 100644 index 000000000..959300547 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/UserApi.java @@ -0,0 +1,137 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.NotNull; + +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 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; + +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiController.java new file mode 100644 index 000000000..2afddc1ec --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@javax.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:/}") +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiDelegate.java new file mode 100644 index 000000000..2ca5e7f1d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiDelegate.java @@ -0,0 +1,125 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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. + */ +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiDelegateImpl.java new file mode 100644 index 000000000..74a761e3b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiDelegateImpl.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Service +public class UserApiDelegateImpl implements UserApiDelegate { + + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Body.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Body.java new file mode 100644 index 000000000..707cfc7a3 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Body.java @@ -0,0 +1,101 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Body1.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Body1.java new file mode 100644 index 000000000..1f91c1e4f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Body1.java @@ -0,0 +1,103 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Category.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Category.java new file mode 100644 index 000000000..b0155127c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Category.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/ModelApiResponse.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/ModelApiResponse.java new file mode 100644 index 000000000..3d3b9c59b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/ModelApiResponse.java @@ -0,0 +1,118 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Order.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Order.java new file mode 100644 index 000000000..bd562704b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Order.java @@ -0,0 +1,230 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Pet.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Pet.java new file mode 100644 index 000000000..a32588dbe --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Pet.java @@ -0,0 +1,245 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotNull; + +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 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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Tag.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Tag.java new file mode 100644 index 000000000..8589d0649 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/Tag.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/User.java new file mode 100644 index 000000000..4f33ce1e1 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app2/model/User.java @@ -0,0 +1,236 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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(java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app20/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app20/HelloController.java new file mode 100644 index 000000000..4435dcde4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app20/HelloController.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotBlank; + +import io.swagger.v3.oas.annotations.Hidden; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/persons") + @Hidden + public void persons(@Valid @NotBlank String name) { + + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app20/SpringDocApp20Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app20/SpringDocApp20Test.java new file mode 100644 index 000000000..5b9a35f6b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app20/SpringDocApp20Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp20Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app21/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app21/HelloController.java new file mode 100644 index 000000000..20e276459 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app21/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotBlank; + +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 org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@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") }))) +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app21/SpringDocApp21Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app21/SpringDocApp21Test.java new file mode 100644 index 000000000..cab45cfa7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app21/SpringDocApp21Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +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 AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app22/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app22/HelloController.java new file mode 100644 index 000000000..70f6f8e44 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app22/HelloController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + + @GetMapping(value = "/persons") + public ResponseEntity>> doGet() { + return null; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app22/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app22/PersonDTO.java new file mode 100644 index 000000000..8a34a0b6b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app22/PersonDTO.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app22/SpringDocApp22Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app22/SpringDocApp22Test.java new file mode 100644 index 000000000..3ac823419 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app22/SpringDocApp22Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp22Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app23/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app23/HelloController.java new file mode 100644 index 000000000..59915d61e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app23/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotBlank; + +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 org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@SecurityScheme(type = SecuritySchemeType.APIKEY, in = SecuritySchemeIn.HEADER, name = "Authorization", paramName = "JWT", description = "A core-auth Bearer token") +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app23/SpringDocApp23Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app23/SpringDocApp23Test.java new file mode 100644 index 000000000..a851bfc9b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app23/SpringDocApp23Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp23Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app24/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app24/HelloController.java new file mode 100644 index 000000000..442d51e12 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app24/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotBlank; + +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 org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@SecurityScheme(type = SecuritySchemeType.APIKEY, in = SecuritySchemeIn.HEADER, name = "Authorization", description = "A core-auth Bearer token") +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app24/SpringDocApp24Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app24/SpringDocApp24Test.java new file mode 100644 index 000000000..d3149fdeb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app24/SpringDocApp24Test.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +public class SpringDocApp24Test extends AbstractSpringDocV30Test { + + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app24/SpringDocTestApp.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app24/SpringDocTestApp.java new file mode 100644 index 000000000..9e2c7105b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app24/SpringDocTestApp.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@SpringBootApplication +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")) + .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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app25/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app25/HelloController.java new file mode 100644 index 000000000..4308127b6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app25/HelloController.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping(value = "/check") + @ResponseStatus(HttpStatus.OK) + void check() { + } + + @GetMapping(value = "/list") + 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) { + } + + @GetMapping(value = "/secondlist") + 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) { + + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app25/SpringDocApp25Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app25/SpringDocApp25Test.java new file mode 100644 index 000000000..240841d3a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app25/SpringDocApp25Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp25Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/Bar.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/Bar.java new file mode 100644 index 000000000..a54d63ca8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/Bar.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Bar { + private String bar; + + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/Foo.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/Foo.java new file mode 100644 index 000000000..0570847ed --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/Foo.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Foo { + + private String foo; + + public String getFoo() { + return foo; + } + + public void setFoo(String foo) { + this.foo = foo; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/HelloController.java new file mode 100644 index 000000000..c8e2ecea4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/HelloController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @PostMapping(value = "/persons") + public MyModel persons(MyModel myModel) { + return new MyModel(); + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/MyModel.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/MyModel.java new file mode 100644 index 000000000..36af43318 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/MyModel.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class MyModel { + + @Schema(description = "Hello", type = "object", oneOf = { Foo.class, Bar.class }) + private Object thing; + + public Object getThing() { + return thing; + } + + public void setThing(Object thing) { + this.thing = thing; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/SpringDocApp26Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/SpringDocApp26Test.java new file mode 100644 index 000000000..022ad5b03 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app26/SpringDocApp26Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp26Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/Advice.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/Advice.java new file mode 100644 index 000000000..5407ff246 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/Advice.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestControllerAdvice +public class Advice { + + @ExceptionHandler(Exception.class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public Foo handleException(Exception ex, WebRequest request) { + return new Foo(); + } + + @ExceptionHandler(MyException.class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public Bar handleMyException(MyException ex, WebRequest request) { + return new Bar(); + } + + @Hidden + @ExceptionHandler(Throwable.class) + @ResponseStatus(HttpStatus.NOT_FOUND) + public Bar handleMyException2(MyException ex, WebRequest request) { + return new Bar(); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/Bar.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/Bar.java new file mode 100644 index 000000000..eb704e75b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/Bar.java @@ -0,0 +1,27 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Bar { + public String bar = "bar"; +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/Foo.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/Foo.java new file mode 100644 index 000000000..126d69f50 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/Foo.java @@ -0,0 +1,27 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Foo { + public String foo = "foo"; +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/HelloController.java new file mode 100644 index 000000000..0fb53052b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/HelloController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + private boolean flag = false; + + @RequestMapping("/") + public String index() { + return ""; + } + + @GetMapping("/test") + public String test() { + flag = !flag; + throw flag ? new MyException() : new RuntimeException(); + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/MyException.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/MyException.java new file mode 100644 index 000000000..78b6af957 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/MyException.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class MyException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/SpringDocApp27Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/SpringDocApp27Test.java new file mode 100644 index 000000000..26bdff7c7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app27/SpringDocApp27Test.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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; + +public class SpringDocApp27Test extends AbstractSpringDocV30Test { + + @Test + public 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"))); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app28/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app28/HelloController.java new file mode 100644 index 000000000..cfc9db067 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app28/HelloController.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app28/SpringDocApp28Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app28/SpringDocApp28Test.java new file mode 100644 index 000000000..b4df527c2 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app28/SpringDocApp28Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp28Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app29/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app29/HelloController.java new file mode 100644 index 000000000..1cea1b380 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app29/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app29/SpringDocApp29Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app29/SpringDocApp29Test.java new file mode 100644 index 000000000..9e27b8a79 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app29/SpringDocApp29Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp29Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app29/TrackerData.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app29/TrackerData.java new file mode 100644 index 000000000..086ce7899 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app29/TrackerData.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Schema(name = "TrackerData") +public class TrackerData { + + @Schema(name = "trackerId", type = "string", required = true, example = "the-tracker-id") + @JsonProperty("trackerId") + String trackerId; + + @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") + @JsonProperty("timestamp") + Instant timestamp; + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app30/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app30/HelloController.java new file mode 100644 index 000000000..7afdd55a2 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app30/HelloController.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app30/SpringDocApp30Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app30/SpringDocApp30Test.java new file mode 100644 index 000000000..8fe016bfe --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app30/SpringDocApp30Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp30Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app31/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app31/HelloController.java new file mode 100644 index 000000000..822e0964e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app31/HelloController.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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; + } + + static class SubscriptionResponse { + private String subscriptionUuid; + + public String getSubscriptionUuid() { + return subscriptionUuid; + } + + public void setSubscriptionUuid(String subscriptionUuid) { + this.subscriptionUuid = subscriptionUuid; + } + + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app31/SpringDocApp31Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app31/SpringDocApp31Test.java new file mode 100644 index 000000000..80575f99a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app31/SpringDocApp31Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp31Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app32/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app32/HelloController.java new file mode 100644 index 000000000..4551886da --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app32/HelloController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @RequestMapping(value = "/filter", method = RequestMethod.POST) + @ResponseStatus(value = HttpStatus.OK) + public String filterPost(@RequestBody final MyTestDto filter) { + return "OK"; + } + + class MyTestDto { + public String object1; + + public String object2; + + public String object3; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app32/SpringDocApp32Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app32/SpringDocApp32Test.java new file mode 100644 index 000000000..dc157d5f5 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app32/SpringDocApp32Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp32Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app33/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app33/HelloController.java new file mode 100644 index 000000000..5ddc79889 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app33/HelloController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app33/SpringDocApp33Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app33/SpringDocApp33Test.java new file mode 100644 index 000000000..91908ef3a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app33/SpringDocApp33Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp33Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app34/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app34/HelloController.java new file mode 100644 index 000000000..8a13296ca --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app34/HelloController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app34/MyExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app34/MyExceptionHandler.java new file mode 100644 index 000000000..77f4731b2 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app34/MyExceptionHandler.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestControllerAdvice +@Hidden +public class MyExceptionHandler extends ResponseEntityExceptionHandler { + @ExceptionHandler(IllegalArgumentException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public Object bad(IllegalArgumentException e) { + return null; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app34/SpringDocApp34Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app34/SpringDocApp34Test.java new file mode 100644 index 000000000..507b77a48 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app34/SpringDocApp34Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp34Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app35/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app35/HelloController.java new file mode 100644 index 000000000..fa7e15ad2 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app35/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Controller +@RequestMapping("/api/v1/poc/") +public class HelloController { + + @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"); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app35/SpringDocApp35Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app35/SpringDocApp35Test.java new file mode 100644 index 000000000..afe17ff71 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app35/SpringDocApp35Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.springdoc.core.SpringDocUtils.getConfig; + +public class SpringDocApp35Test extends AbstractSpringDocV30Test { + + static { + getConfig().addRestControllers(HelloController.class); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app36/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app36/HelloController.java new file mode 100644 index 000000000..619085a31 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app36/HelloController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app36/SpringDocApp36Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app36/SpringDocApp36Test.java new file mode 100644 index 000000000..70737ba78 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app36/SpringDocApp36Test.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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 AbstractSpringDocV30Test { + + @Test + public 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/Bar.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/Bar.java new file mode 100644 index 000000000..5aaa75a42 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/Bar.java @@ -0,0 +1,27 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Bar { + public String bar = "bar"; +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/Car.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/Car.java new file mode 100644 index 000000000..4fa05665e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/Car.java @@ -0,0 +1,28 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Car { + public String car = "car"; + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/Foo.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/Foo.java new file mode 100644 index 000000000..6106fbe29 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/Foo.java @@ -0,0 +1,27 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Foo { + public String foo = "foo"; +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/HelloController.java new file mode 100644 index 000000000..4607895bf --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/HelloController.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; + +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +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; + +@RestController("/api") +public class HelloController { + + @PostMapping(path = "/bar/baz", consumes = "application/x.a+json", produces = MediaType.TEXT_PLAIN_VALUE) + public Foo process(@RequestBody Foo a) { + return a; + } + + @PostMapping(path = "/bar/baz", consumes = "application/x.b+json", produces = MediaType.TEXT_PLAIN_VALUE) + public Bar process(@RequestBody Bar b) { + return b; + } + + @PostMapping(path = "/bar/baz", consumes = "application/x.c+json", produces = MediaType.APPLICATION_JSON_VALUE) + public Car process(@RequestBody Car c) { + return c; + } + + @PostMapping(value = "/pets", consumes = "application/json") + public ResponseEntity petsPost(@Valid @RequestBody Pet pet) { + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + @PostMapping(value = "/pets", consumes = "text/plain") + public ResponseEntity petsPost(@Valid @RequestBody String pet) { + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/Pet.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/Pet.java new file mode 100644 index 000000000..dcf04a5c7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/Pet.java @@ -0,0 +1,28 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class Pet { + public String pet = "pet"; + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/SpringDocApp37Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/SpringDocApp37Test.java new file mode 100644 index 000000000..78650f699 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app37/SpringDocApp37Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp37Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app38/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app38/HelloController.java new file mode 100644 index 000000000..29ca3760b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app38/HelloController.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController("/api") +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app38/SpringDocApp38Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app38/SpringDocApp38Test.java new file mode 100644 index 000000000..4e4205058 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app38/SpringDocApp38Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp38Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app39/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app39/HelloController.java new file mode 100644 index 000000000..01b0afb95 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app39/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @Operation(summary = "test Request") + @RequestBody(description = "test value", required = true, content = @Content(schema = @Schema(implementation = String.class))) + @PostMapping("/test") + public void searchEmployee(String test) { + } + + @GetMapping("/hello") + public String hello() { + return "hello"; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app39/SpringDocApp39Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app39/SpringDocApp39Test.java new file mode 100644 index 000000000..7a8b698fe --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app39/SpringDocApp39Test.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +public class SpringDocApp39Test extends AbstractSpringDocV30Test { + + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app39/SpringDocTestApp.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app39/SpringDocTestApp.java new file mode 100644 index 000000000..ca73d8cb7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app39/SpringDocTestApp.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.OpenApiCustomiser; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +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 OpenApiCustomiser customerGlobalHeaderOpenApiCustomiser() { + 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app4/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app4/HelloController.java new file mode 100644 index 000000000..51788dcfc --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app4/HelloController.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @PostMapping(value = "/values/data") + TrackerData list(TrackerData toto) { + return toto; + + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java new file mode 100644 index 000000000..dfca9cb2a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.use-fqn=true") +public class SpringDocApp4Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + @AfterAll + static void restore(){ + TypeNameResolver.std.setUseFqn(false); + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app4/TrackerData.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app4/TrackerData.java new file mode 100644 index 000000000..31fa6bcbb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app4/TrackerData.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class TrackerData { + + @Schema(name = "trackerId", type = "string", required = true, example = "the-tracker-id") + @JsonProperty("trackerId") + String trackerId; + + @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") + @JsonProperty("timestamp") + Instant timestamp; + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app40/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app40/HelloController.java new file mode 100644 index 000000000..06471638d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app40/HelloController.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController("/api") +public class HelloController { + + @RequestMapping(value = "/iae_error", method = RequestMethod.GET) + public ObjectNode getStartFormProperties() { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app40/SpringDocApp40Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app40/SpringDocApp40Test.java new file mode 100644 index 000000000..c1b5a4349 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app40/SpringDocApp40Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp40Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app41/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app41/HelloController.java new file mode 100644 index 000000000..fb72e2196 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app41/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotNull; + +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.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; + +@RestController("/api") +public class HelloController { + + @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 = java.lang.Error.class))), + @ApiResponse(responseCode = "500", description = "Unexpected error", content = @Content(schema = @Schema(implementation = java.lang.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app41/SpringDocApp411Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app41/SpringDocApp411Test.java new file mode 100644 index 000000000..1dff416d9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app41/SpringDocApp411Test.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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; + +public class SpringDocApp411Test extends AbstractSpringDocV30Test { + + @Test + public 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); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app41/SpringDocApp41Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app41/SpringDocApp41Test.java new file mode 100644 index 000000000..89232321d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app41/SpringDocApp41Test.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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; + +@TestPropertySource(properties = "springdoc.cache.disabled=true") +public class SpringDocApp41Test extends AbstractSpringDocV30Test { + + @Test + public 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); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app42/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app42/HelloController.java new file mode 100644 index 000000000..9bfc1e90c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app42/HelloController.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +@RestController("/api") +public class HelloController { + + @GetMapping(value = "/tweets") + public void tweets(@PathVariable TweetId id) { + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app42/SpringDocApp42Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app42/SpringDocApp42Test.java new file mode 100644 index 000000000..2dedbb7c7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app42/SpringDocApp42Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp42Test extends AbstractSpringDocV30Test { + + + @SpringBootApplication + static class SpringDocTestApp { + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app42/TweetId.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app42/TweetId.java new file mode 100644 index 000000000..5b2952b46 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app42/TweetId.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class TweetId { + private final String value; + + public TweetId(String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app43/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app43/HelloController.java new file mode 100644 index 000000000..b3cd78ee7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app43/HelloController.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @PostMapping(path = "/documents", consumes = "multipart/form-data") + public ResponseEntity uploadDocuments(@RequestPart("doc") List multipartFiles) { + return null; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app43/SpringDocApp43Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app43/SpringDocApp43Test.java new file mode 100644 index 000000000..cb41ad6ef --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app43/SpringDocApp43Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp43Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app44/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app44/HelloController.java new file mode 100644 index 000000000..332c99b02 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app44/HelloController.java @@ -0,0 +1,129 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController("/api") +public class HelloController { + + @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)); + } + + @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)); + } + + static class RequestV1 { + private String nameV1; + + public RequestV1() { + } + + public String getNameV1() { + return nameV1; + } + + public void setNameV1(String nameV1) { + this.nameV1 = nameV1; + } + } + + static class RequestV2 { + private String nameV2; + + public RequestV2() { + } + + public String getNameV2() { + return nameV2; + } + + public void setNameV2(String nameV2) { + this.nameV2 = nameV2; + } + } + + class HelloDTO1 { + private String message; + + public HelloDTO1(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + } + + class HelloDTO2 { + private String message; + + public HelloDTO2(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + } + + class ErrorDTO { + private String errorMessage; + + public ErrorDTO(String errorMessage) { + this.errorMessage = errorMessage; + } + + public String getErrorMessage() { + return errorMessage; + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app44/SpringDocApp44Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app44/SpringDocApp44Test.java new file mode 100644 index 000000000..5d7195f04 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app44/SpringDocApp44Test.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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; + +public class SpringDocApp44Test extends AbstractSpringDocV30Test { + + @Test + public 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"))); + + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/HelloController.java new file mode 100644 index 000000000..f8585f389 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/HelloController.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +@Tag(name = "People", description = "Use this resource to serve all requests and initiate all operations related to people") +@RestController +@RequestMapping(value = "/v1/people") +public class HelloController { + + + @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); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/HelloController2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/HelloController2.java new file mode 100644 index 000000000..e79c14b35 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/HelloController2.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +@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") +public class HelloController2 { + + + @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); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/OpenApiConfig.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/OpenApiConfig.java new file mode 100644 index 000000000..11ccaa997 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/OpenApiConfig.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/PersonDTO.java new file mode 100644 index 000000000..3ec4d1b82 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/PersonDTO.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/SpringDocApp45Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/SpringDocApp45Test.java new file mode 100644 index 000000000..742fcffbf --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app45/SpringDocApp45Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp45Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app46/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app46/HelloController.java new file mode 100644 index 000000000..703a0a154 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app46/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app46/SpringDocApp46Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app46/SpringDocApp46Test.java new file mode 100644 index 000000000..14233c56a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app46/SpringDocApp46Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp46Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app47/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app47/HelloController.java new file mode 100644 index 000000000..e8dfa9a91 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app47/HelloController.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + @GetMapping(path = "/documents/{locale}") + public ResponseEntity getDocumentsWithLocale( + @Parameter(schema = @Schema(type = "string")) @PathVariable("locale") Locale locale) { + return null; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app47/SpringDocApp47Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app47/SpringDocApp47Test.java new file mode 100644 index 000000000..fb1061959 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app47/SpringDocApp47Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp47Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app48/AbstractHelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app48/AbstractHelloController.java new file mode 100644 index 000000000..24d9488aa --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app48/AbstractHelloController.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@ApiResponse(responseCode = "410") +@ApiResponses({ + @ApiResponse(responseCode = "411") +}) +public class AbstractHelloController { + + @GetMapping(path = "/documents/{locale}") + @ApiResponse(responseCode = "412") + @ApiResponses({ + @ApiResponse(responseCode = "413") + }) + public ResponseEntity getDocuments() { + return null; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app48/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app48/HelloController.java new file mode 100644 index 000000000..3b04bf230 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app48/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController + +@ApiResponse(responseCode = "400") +@ApiResponses({ + @ApiResponse(responseCode = "401") +}) +public class HelloController extends AbstractHelloController { + + @Override + @GetMapping(path = "/documents/{locale}") + @ApiResponse(responseCode = "402") + @ApiResponses({ + @ApiResponse(responseCode = "403") + }) + public ResponseEntity getDocuments() { + return null; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app48/SpringDocApp48Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app48/SpringDocApp48Test.java new file mode 100644 index 000000000..b385a4369 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app48/SpringDocApp48Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp48Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app49/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app49/HelloController.java new file mode 100644 index 000000000..b7e1b2601 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app49/HelloController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app49/SpringDocApp49Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app49/SpringDocApp49Test.java new file mode 100644 index 000000000..7897737bd --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app49/SpringDocApp49Test.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +public class SpringDocApp49Test extends AbstractSpringDocV30Test { + + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app49/SpringDocTestApp.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app49/SpringDocTestApp.java new file mode 100644 index 000000000..118f72673 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app49/SpringDocTestApp.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@SpringBootApplication +public class SpringDocTestApp { + + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app5/CustomOpenAPIConfig.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app5/CustomOpenAPIConfig.java new file mode 100644 index 000000000..7dc1ac846 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app5/CustomOpenAPIConfig.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class CustomOpenAPIConfig { + @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-webmvc-core/src/test/java/test/org/springdoc/api/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java similarity index 84% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java index e7b7f487a..3b7e9e406 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java @@ -1,22 +1,26 @@ /* * - * * Copyright 2019-2020 the original author or authors. * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; +package test.org.springdoc.api.v30.app5.sample; import java.util.ArrayList; @@ -28,7 +32,7 @@ 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 test.org.springdoc.api.v30.AbstractSpringDocV30Test; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.TestConfiguration; @@ -41,7 +45,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") -public class OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest extends AbstractSpringDocTest { +public class OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest extends AbstractSpringDocV30Test { /** * Given: Bean configuration with security scheme http basic (shouldDefineComponentsSecuritySchemesForHttpBasic) diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenApiResourceCustomConfigurationTest.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenApiResourceCustomConfigurationTest.java new file mode 100644 index 000000000..1f6ad7e01 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenApiResourceCustomConfigurationTest.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; +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; + +@Import(CustomOpenAPIConfig.class) +@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") +public class OpenApiResourceCustomConfigurationTest extends AbstractSpringDocV30Test { + + /** + * givenNoConfiguration_whenGetApiJson_returnsDefaultEmptyDocs - should return + * {"openapi":"3.0.1","info":{"title":"Custom API","version":"100"},"paths":{},"components":{}} + */ + @Test + public 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"))); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenApiResourceNoConfigurationTest.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenApiResourceNoConfigurationTest.java new file mode 100644 index 000000000..e42e1d030 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenApiResourceNoConfigurationTest.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +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; + +@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") +public class OpenApiResourceNoConfigurationTest extends AbstractSpringDocV30Test { + + /** + * givenNoConfiguration_whenGetApiJson_returnsDefaultEmptyDocs - should return + * {"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"paths":{},"components":{}} + */ + @Test + public 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()); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app50/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app50/HelloController.java new file mode 100644 index 000000000..e8d69e7f7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app50/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app50/SpringDocApp50Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app50/SpringDocApp50Test.java new file mode 100644 index 000000000..cee2296cf --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app50/SpringDocApp50Test.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +public class SpringDocApp50Test extends AbstractSpringDocV30Test { + + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app50/SpringDocTestApp.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app50/SpringDocTestApp.java new file mode 100644 index 000000000..f7b6de335 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app50/SpringDocTestApp.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@SpringBootApplication +public class SpringDocTestApp { + + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app51/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app51/HelloController.java new file mode 100644 index 000000000..218c34c24 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app51/HelloController.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @Operation(parameters = { + @Parameter(in = ParameterIn.HEADER, name = "test_header", required = true, schema = @Schema(type = "string", example = "rherherherherh")) }) + @GetMapping("/test1") + public String test1() { + return "test"; + } + + @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"; + } + + @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"; + } + + @GetMapping("/test") + public String get( + @PathVariable String path, + @RequestParam(required = false) Map params) { + return null; + } + + @PostMapping + public ResponseEntity> hello(@RequestBody HashMap map) { + return ResponseEntity.ok(map); + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app51/SpringDocApp51Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app51/SpringDocApp51Test.java new file mode 100644 index 000000000..2474eb61c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app51/SpringDocApp51Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp51Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app52/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app52/HelloController.java new file mode 100644 index 000000000..c1cb343f0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app52/HelloController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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; + } + + @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; + } + + @PostMapping(value = "/test3", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public String createTest3(@RequestPart("test") MyTestDto test, + @RequestPart("doc") List multipartFiles) { + return null; + } + + class MyTestDto { + public String object1; + + public String object2; + + public String object3; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app52/SpringDocApp52Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app52/SpringDocApp52Test.java new file mode 100644 index 000000000..e5a2bd015 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app52/SpringDocApp52Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp52Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app53/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app53/HelloController.java new file mode 100644 index 000000000..411ba4a06 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app53/HelloController.java @@ -0,0 +1,97 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @Operation(description = "Some operation") + @GetMapping(value = "/hello1", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithNoApiResponse() { + return null; + } + + @Operation(description = "Some operation") + @ApiResponse + @GetMapping(value = "/hello2", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithEmptyApiResponse() { + return null; + } + + @Operation(description = "Some operation") + @GetMapping(value = "/hello3", produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.NO_CONTENT) + List listWithExplicitResponseStatus() { + return null; + } + + @Operation(description = "Some operation") + @GetMapping(value = "/hello4", produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.NO_CONTENT) + HelloDTO1 getDTOWithExplicitResponseStatus() { + return null; + } + + @Operation(description = "Some operation") + @GetMapping(value = "/hello5", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithDefaultResponseStatus() { + return null; + } + + @Operation(description = "Some operation") + @GetMapping(value = "/hello6", produces = MediaType.APPLICATION_JSON_VALUE) + HelloDTO1 getDTOWithDefaultResponseStatus() { + return null; + } + + @Operation(description = "Some operation") + @GetMapping(value = "/hello7", produces = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity getNestedDTOWithDefaultResponseStatus() { + return null; + } + + static class HelloDTO1 { + private String message; + + public HelloDTO1(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app53/HelloControllerWithGlobalApiResponse.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app53/HelloControllerWithGlobalApiResponse.java new file mode 100644 index 000000000..7443569a0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app53/HelloControllerWithGlobalApiResponse.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping(path = "/global") +public class HelloControllerWithGlobalApiResponse { + + @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; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app53/SpringDocApp53Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app53/SpringDocApp53Test.java new file mode 100644 index 000000000..299dff910 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app53/SpringDocApp53Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp53Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app54/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app54/HelloController.java new file mode 100644 index 000000000..63ec67dad --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app54/HelloController.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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; + } + + @JsonView(Views.MealPartyAdmin.class) + @PostMapping(value = "/parties") + public ResponseEntity saveMealParty(@JsonView(Views.Public.class) @RequestBody MealParty p) { + return null; + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app54/MealParty.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app54/MealParty.java new file mode 100644 index 000000000..24d229053 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app54/MealParty.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class MealParty { + @JsonView(Views.Public.class) + private String name; + + @JsonView(Views.MealPartyAdmin.class) + private List members = new ArrayList<>(); +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app54/SpringDocApp54Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app54/SpringDocApp54Test.java new file mode 100644 index 000000000..ceb5a3404 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app54/SpringDocApp54Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp54Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app54/Views.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app54/Views.java new file mode 100644 index 000000000..b6d71b6e1 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app54/Views.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public interface Views { + public interface Public { + } + + public interface MealPartyAdmin extends Public { + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app55/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app55/HelloController.java new file mode 100644 index 000000000..df3eb2789 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app55/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Controller +@Tag(name = "health") +public class HelloController { + + /** + * Ping endpoint used for health checks. + */ + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app55/SpringDocApp55Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app55/SpringDocApp55Test.java new file mode 100644 index 000000000..f0a8ebf86 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app55/SpringDocApp55Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp55Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app56/GlobalExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app56/GlobalExceptionHandler.java new file mode 100644 index 000000000..6138f7a09 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app56/GlobalExceptionHandler.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestControllerAdvice +public class GlobalExceptionHandler { + @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: "); + } + + class ErrorDTO { + private String errorMessage; + + ErrorDTO(String errorMessage) { + this.errorMessage = errorMessage; + } + + public String getErrorMessage() { + return errorMessage; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app56/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app56/HelloController.java new file mode 100644 index 000000000..991b144bf --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app56/HelloController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app56/SpringDocApp56Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app56/SpringDocApp56Test.java new file mode 100644 index 000000000..6ab03960e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app56/SpringDocApp56Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp56Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app57/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app57/HelloController.java new file mode 100644 index 000000000..ac01bd17b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app57/HelloController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping("/{name:.+}") + public ResponseEntity getText(@Parameter(description = "desc", required = true) @PathVariable String name) { + return null; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app57/SpringDocApp57Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app57/SpringDocApp57Test.java new file mode 100644 index 000000000..eef3e8682 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app57/SpringDocApp57Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp57Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app58/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app58/HelloController.java new file mode 100644 index 000000000..fe4d392ac --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app58/HelloController.java @@ -0,0 +1,103 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @PostMapping("/examplePost") + @Operation(summary = "schema example") + public Object example(@Parameter(schema = @Schema(hidden = true)) JsonNode json) { + return null; + } + + @GetMapping("/example") + public void test(@Parameter(schema = @Schema(hidden = true)) JsonNode json) { + } + + @GetMapping(value = "/foo") + public void foobar(@Parameter(description = "User", name = "user", + schema = @Schema(implementation = PersonDTO.class)) @RequestParam("bar") String 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) { + + } + + 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app58/SpringDocApp58Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app58/SpringDocApp58Test.java new file mode 100644 index 000000000..f8bcee203 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app58/SpringDocApp58Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp58Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/HelloBody.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/HelloBody.java new file mode 100644 index 000000000..49290148e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/HelloBody.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotNull; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class HelloBody { + + @NotNull + @JsonProperty + private String helloValue; + + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/HelloController.java new file mode 100644 index 000000000..f0e911775 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/HelloController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.validation.annotation.Validated; +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 { + @Deprecated + @GetMapping("/example") + public void test() { + } + + @PostMapping("/hello") + @ApiResponse(responseCode = "200", description = "The server accepted your hello.") + String hello(@Validated @RequestBody final HelloBody helloBody) { + return "World!"; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/HelloController2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/HelloController2.java new file mode 100644 index 000000000..d278fb693 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/HelloController2.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.validation.annotation.Validated; +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 +@Deprecated +public class HelloController2 { + + @GetMapping("/example2") + public void test() { + } + + @PostMapping("/hello2") + @ApiResponse(responseCode = "200", description = "The server accepted your hello.") + String hello(@Validated @RequestBody final HelloBody helloBody) { + return "World!"; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/HelloExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/HelloExceptionHandler.java new file mode 100644 index 000000000..ced2a8ffe --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/HelloExceptionHandler.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.context.request.WebRequest; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; + +@Order(Ordered.HIGHEST_PRECEDENCE) +@RestControllerAdvice +public class HelloExceptionHandler extends ResponseEntityExceptionHandler { + + @ExceptionHandler(Exception.class) + @ResponseBody + @ApiResponse(responseCode = "500", + description = "An unknown error occurred" + ) + protected ResponseEntity handleException() { + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + + @Override + @ApiResponse(responseCode = "400", + description = "The request is malformed or information is missing." + ) + protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/SpringDocApp59Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/SpringDocApp59Test.java new file mode 100644 index 000000000..e0f141a12 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app59/SpringDocApp59Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp59Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app6/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app6/HelloController.java new file mode 100644 index 000000000..dcdce7549 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app6/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java new file mode 100644 index 000000000..1ba0d137b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp6Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app60/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app60/HelloController.java new file mode 100644 index 000000000..05f828823 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app60/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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; + } + + @GetMapping("/hello2") + @Operation(summary = "summary2") + @QuerySort + @QueryPaging + public List list2(String page, String size, String sort) { + return null; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app60/QueryPaging.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app60/QueryPaging.java new file mode 100644 index 000000000..4aa9aadbb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app60/QueryPaging.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app60/QuerySort.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app60/QuerySort.java new file mode 100644 index 000000000..f9fa0c0fe --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app60/QuerySort.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.METHOD }) +@Parameter(name = "sort", description = "desc sort from Annotated interface") +public @interface QuerySort { +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app60/SpringDocApp60Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app60/SpringDocApp60Test.java new file mode 100644 index 000000000..8b868ae2f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app60/SpringDocApp60Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp60Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app61/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app61/HelloController.java new file mode 100644 index 000000000..fa2c60d43 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app61/HelloController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app61/SpringDocApp61Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app61/SpringDocApp61Test.java new file mode 100644 index 000000000..a2c149db9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app61/SpringDocApp61Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp61Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app62/BaseController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app62/BaseController.java new file mode 100644 index 000000000..3966113aa --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app62/BaseController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Target({ ElementType.METHOD, ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@RestController +@RequestMapping +public @interface BaseController { + @AliasFor(annotation = RequestMapping.class) + String[] value() default {}; + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app62/SpringDocApp62Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app62/SpringDocApp62Test.java new file mode 100644 index 000000000..f77623fa7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app62/SpringDocApp62Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp62Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app62/TestController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app62/TestController.java new file mode 100644 index 000000000..ca8bc815a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app62/TestController.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@BaseController +@Tag(name = "Test Controller") +public class TestController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app63/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app63/HelloController.java new file mode 100644 index 000000000..9959eefd5 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app63/HelloController.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app63/SpringDocApp63Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app63/SpringDocApp63Test.java new file mode 100644 index 000000000..68add178e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app63/SpringDocApp63Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +@TestPropertySource(properties = { + "springdoc.packagesToScan=hell,hello1, hello.me", + "springdoc.packagesToExclude=test.org.springdoc.api.app63.65" }) +public class SpringDocApp63Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app64/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app64/HelloController.java new file mode 100644 index 000000000..4db6f76e0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app64/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app64/SpringDocApp64Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app64/SpringDocApp64Test.java new file mode 100644 index 000000000..cd2f1d1bf --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app64/SpringDocApp64Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.paths-to-match=/v1, /api/**") +public class SpringDocApp64Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app65/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app65/HelloController.java new file mode 100644 index 000000000..623be3b39 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app65/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app65/SpringDocApp65Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app65/SpringDocApp65Test.java new file mode 100644 index 000000000..f3ed62094 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app65/SpringDocApp65Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp65Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app66/DefaultHealthCheckApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app66/DefaultHealthCheckApi.java new file mode 100644 index 000000000..4b0a9fe72 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app66/DefaultHealthCheckApi.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +@RestController +@Hidden +public class DefaultHealthCheckApi { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app66/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app66/HelloController.java new file mode 100644 index 000000000..da94747f3 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app66/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@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(UndocumentedClass possiblyInjectedByAspect) { + return ResponseEntity.ok("Healthy"); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app66/SpringDocApp66Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app66/SpringDocApp66Test.java new file mode 100644 index 000000000..ad17dd93f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app66/SpringDocApp66Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp66Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app66/UndocumentedClass.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app66/UndocumentedClass.java new file mode 100644 index 000000000..0d1740730 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app66/UndocumentedClass.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Hidden +public class UndocumentedClass { + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app67/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app67/HelloController.java new file mode 100644 index 000000000..5787a6656 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app67/HelloController.java @@ -0,0 +1,108 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping(path = "/demo", + produces = MediaType.TEXT_PLAIN_VALUE) +public class HelloController { + + @GetMapping("operation1") + @Operation(summary = "Operation 1 (expected result - no parameters)") + public String operation1() { + return "operation1"; + } + + @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"; + } + + @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"; + } + + @GetMapping("operation4") + @Operation(summary = "Operation 4 (expected result - 3 parameters)") + @QueryPaging + @QuerySort + public String operation4() { + return "operation4"; + } + + @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 { + + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app67/SpringDocApp67Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app67/SpringDocApp67Test.java new file mode 100644 index 000000000..d709f1e3e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app67/SpringDocApp67Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp67Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/CustomizedOperation.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/CustomizedOperation.java new file mode 100644 index 000000000..c3bec98b6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/CustomizedOperation.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/SpringDocApp68Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/SpringDocApp68Test.java new file mode 100644 index 000000000..ebf648d77 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/SpringDocApp68Test.java @@ -0,0 +1,102 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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 AbstractSpringDocV30Test { + + public static String className; + + @Test + public 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 + public 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 + public 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 + public 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 + public 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 + public 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 + public void testApp5() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/user")) + .andExpect(status().isNotFound()); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/SpringDocTestApp.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/SpringDocTestApp.java new file mode 100644 index 000000000..a78fc1e61 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/SpringDocTestApp.java @@ -0,0 +1,121 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import org.springdoc.core.GroupedOpenApi; +import org.springdoc.core.customizers.OpenApiCustomiser; +import org.springdoc.core.customizers.OperationCustomizer; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.web.method.HandlerMethod; + +@SpringBootApplication +public class SpringDocTestApp { + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @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").addOpenApiCustomiser(serverOpenApiCustomiser1()) + .addOperationCustomizer(operationCustomizer()) + .build(); + } + + public OpenApiCustomiser serverOpenApiCustomiser1() { + Server server = new Server().url("http://toto.v1.com").description("myserver1"); + List servers = new ArrayList<>(); + servers.add(server); + return openApi -> openApi.setServers(servers); + } + + public OpenApiCustomiser serverOpenApiCustomiser2() { + 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/**").addOpenApiCustomiser(serverOpenApiCustomiser2()) + .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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/ApiUtil.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/ApiUtil.java new file mode 100644 index 000000000..107da3ac1 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/ApiUtil.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/ExceptionTranslator.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/ExceptionTranslator.java new file mode 100644 index 000000000..5c397dd36 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/ExceptionTranslator.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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("javax.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); + return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/HomeController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/HomeController.java new file mode 100644 index 000000000..fe3bcb73e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/HomeController.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApi.java new file mode 100644 index 000000000..c843af30b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApi.java @@ -0,0 +1,166 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.NotNull; + +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 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiController.java new file mode 100644 index 000000000..939925a58 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiDelegate.java new file mode 100644 index 000000000..82a106e9d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiDelegate.java @@ -0,0 +1,146 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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. + */ +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiDelegateImpl.java new file mode 100644 index 000000000..0fc1c6f72 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiDelegateImpl.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApi.java new file mode 100644 index 000000000..f04000ed8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApi.java @@ -0,0 +1,109 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; + +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 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; + +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiController.java new file mode 100644 index 000000000..78ec9ac3f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiDelegate.java new file mode 100644 index 000000000..d15031296 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiDelegate.java @@ -0,0 +1,97 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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. + */ +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiDelegateImpl.java new file mode 100644 index 000000000..7116a1828 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiDelegateImpl.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApi.java new file mode 100644 index 000000000..b13be29f4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApi.java @@ -0,0 +1,137 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.NotNull; + +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 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; + +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiController.java new file mode 100644 index 000000000..24a271223 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiDelegate.java new file mode 100644 index 000000000..eb806ba0a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiDelegate.java @@ -0,0 +1,126 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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. + */ +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiDelegateImpl.java new file mode 100644 index 000000000..3aac4eda2 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiDelegateImpl.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserClient.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserClient.java new file mode 100644 index 000000000..e58f49210 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserClient.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Body.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Body.java new file mode 100644 index 000000000..273bac306 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Body.java @@ -0,0 +1,101 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Body1.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Body1.java new file mode 100644 index 000000000..d3201926b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Body1.java @@ -0,0 +1,103 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Category.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Category.java new file mode 100644 index 000000000..15bae0da9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Category.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/ModelApiResponse.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/ModelApiResponse.java new file mode 100644 index 000000000..2cc51c374 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/ModelApiResponse.java @@ -0,0 +1,118 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Order.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Order.java new file mode 100644 index 000000000..638aed9ef --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Order.java @@ -0,0 +1,230 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Pet.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Pet.java new file mode 100644 index 000000000..3e43e4d2c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Pet.java @@ -0,0 +1,245 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotNull; + +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 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Tag.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Tag.java new file mode 100644 index 000000000..79e7b1995 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/Tag.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/User.java new file mode 100644 index 000000000..dbb18c682 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app68/model/User.java @@ -0,0 +1,236 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app69/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app69/HelloController.java new file mode 100644 index 000000000..d186ce67d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app69/HelloController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @RequestMapping(value = "/tasks", method = RequestMethod.GET) + private Callable> getTasks(String str) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app69/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app69/PersonDTO.java new file mode 100644 index 000000000..040963ce5 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app69/PersonDTO.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app69/SpringDocApp69Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app69/SpringDocApp69Test.java new file mode 100644 index 000000000..1236161a1 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app69/SpringDocApp69Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp69Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app7/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app7/HelloController.java new file mode 100644 index 000000000..4449d2840 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app7/HelloController.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java new file mode 100644 index 000000000..0de91445f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp7Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/HelloController.java new file mode 100644 index 000000000..26f2b541e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/SpringDocApp70Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/SpringDocApp70Test.java new file mode 100644 index 000000000..562ccc0e1 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/SpringDocApp70Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp70Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedOperation.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedOperation.java new file mode 100644 index 000000000..846001d78 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedOperation.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomizedOperation { + String addition() default "customized operation!"; +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedParameter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedParameter.java new file mode 100644 index 000000000..a4d7a5eda --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedParameter.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomizedParameter { + String addition() default "customized parameter!"; +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedProperty.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedProperty.java new file mode 100644 index 000000000..120154006 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedProperty.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomizedProperty { + String addition() default "customized property!"; +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/OperationCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/OperationCustomizer.java new file mode 100644 index 000000000..3bc55c143 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/OperationCustomizer.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Component +public class OperationCustomizer implements org.springdoc.core.customizers.OperationCustomizer { + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/ParameterCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/ParameterCustomizer.java new file mode 100644 index 000000000..1c4bfc57f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/ParameterCustomizer.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Component +public class ParameterCustomizer implements org.springdoc.core.customizers.ParameterCustomizer { + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/PropertyCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/PropertyCustomizer.java new file mode 100644 index 000000000..e68cf7575 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/customizer/PropertyCustomizer.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Component +public class PropertyCustomizer implements org.springdoc.core.customizers.PropertyCustomizer { + + @Autowired + ObjectMapperProvider objectMapperProvider; + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/model/ApiType.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/model/ApiType.java new file mode 100644 index 000000000..ccdef3c61 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app70/model/ApiType.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class ApiType { + @CustomizedProperty + @Schema(description = "Test description") + @JsonProperty("someProperty") + private Duration someProperty; + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app71/Dog.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app71/Dog.java new file mode 100644 index 000000000..c217acd12 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app71/Dog.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +@Schema(name = "Dog") +public class Dog { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app71/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app71/HelloController.java new file mode 100644 index 000000000..5b2e69f74 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app71/HelloController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @PostMapping("/persons") + public String persons(Dog dog) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app71/SpringDocApp71Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app71/SpringDocApp71Test.java new file mode 100644 index 000000000..faa2b4d89 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app71/SpringDocApp71Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp71Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app72/BlockingAutoConfigurationTest.java similarity index 76% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app72/BlockingAutoConfigurationTest.java index 3a0dfbaf0..aa00439fe 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app72/BlockingAutoConfigurationTest.java @@ -1,22 +1,26 @@ /* * - * * Copyright 2019-2020 the original author or authors. * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * * * - * * https://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; +package test.org.springdoc.api.v30.app72; import org.junit.jupiter.api.Test; import org.springdoc.core.GroupedOpenApi; diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app72/CacheAutoConfigurationTest1.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app72/CacheAutoConfigurationTest1.java new file mode 100644 index 000000000..2eaf745da --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app72/CacheAutoConfigurationTest1.java @@ -0,0 +1,89 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 + public void cache_configuration_loaded_when_not_disabled_explicitly() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + @Test + public 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 + public void cache_configurations_successfully_disabled() { + contextRunner + .withPropertyValues("springdoc.cache.disabled=true") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + @Test + public 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app72/GroupAutoConfigurationTest.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app72/GroupAutoConfigurationTest.java new file mode 100644 index 000000000..e5c8b5be7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app72/GroupAutoConfigurationTest.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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 + public 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app73/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app73/HelloController.java new file mode 100644 index 000000000..34f6d73c2 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app73/HelloController.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +@RestController +@RequestMapping({ "/{country_code}/persons/", "/persons" }) +public class HelloController { + + @DeleteMapping("/{id}") + @ResponseStatus(HttpStatus.NO_CONTENT) + public void delete(@Parameter(name = "country_code", in = ParameterIn.PATH) String countryCode, @PathVariable("id") String id) { + + } + + @GetMapping("/{id}") + public String get(@Parameter(name = "country_code", in = ParameterIn.PATH) String countryCode, @PathVariable("id") String id) { + return null; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app73/SpringDocApp73Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app73/SpringDocApp73Test.java new file mode 100644 index 000000000..df25f6386 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app73/SpringDocApp73Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp73Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app74/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app74/HelloController.java new file mode 100644 index 000000000..276fd2c7f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app74/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +@RestController +public class HelloController { + + @PostMapping("/test") + @RequestBody( + content = @Content( + examples = @ExampleObject( + value = "sample" + ) + ) + ) + public String postMyRequestBody( + String myRequestBody) { + return null; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app74/SpringDocApp74Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app74/SpringDocApp74Test.java new file mode 100644 index 000000000..f6463d77b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app74/SpringDocApp74Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp74Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app75/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app75/HelloController.java new file mode 100644 index 000000000..c611ff67a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app75/HelloController.java @@ -0,0 +1,105 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @PostMapping("/test1") + @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; + } + + @PostMapping("/test2") + @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; + } + + @PostMapping("/test3") + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app75/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app75/PersonDTO.java new file mode 100644 index 000000000..31774859f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app75/PersonDTO.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app75/RestResponseEntityExceptionHandler.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app75/RestResponseEntityExceptionHandler.java new file mode 100644 index 000000000..49bcab26f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app75/RestResponseEntityExceptionHandler.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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; + +@ControllerAdvice +public class RestResponseEntityExceptionHandler + extends ResponseEntityExceptionHandler { + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app75/SpringDocApp75Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app75/SpringDocApp75Test.java new file mode 100644 index 000000000..66d80db3f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app75/SpringDocApp75Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp75Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app76/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app76/HelloController.java new file mode 100644 index 000000000..9686e05fb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app76/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +@RestController +public class HelloController { + + @GetMapping("/secure") + @ResponseBody + public String secured() { + return "It works!"; + } + + @GetMapping("/open") + @ResponseBody + @SecurityRequirements + public String open() { + return "It works!"; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app76/SpringDocApp76Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app76/SpringDocApp76Test.java new file mode 100644 index 000000000..c8c14c706 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app76/SpringDocApp76Test.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp76Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app77/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app77/HelloController.java new file mode 100644 index 000000000..b25468475 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app77/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; + +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 org.hibernate.validator.constraints.NotBlank; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class HelloController { + + @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) { + + } + + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app77/SpringDocApp77Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app77/SpringDocApp77Test.java new file mode 100644 index 000000000..d15a1afe9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app77/SpringDocApp77Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp77Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app78/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app78/HelloController.java new file mode 100644 index 000000000..8e9cf4307 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app78/HelloController.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @RequestMapping(value = "/person1", method = RequestMethod.GET) + private CompletionStage> getPerson1(String str) { + return null; + } + + @RequestMapping(value = "/person2", method = RequestMethod.GET) + private CompletableFuture getPerson2(String str) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app78/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app78/PersonDTO.java new file mode 100644 index 000000000..223540660 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app78/PersonDTO.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app78/SpringDocApp78Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app78/SpringDocApp78Test.java new file mode 100644 index 000000000..20712a7b1 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app78/SpringDocApp78Test.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp78Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app79/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app79/HelloController.java new file mode 100644 index 000000000..f43b1bfc7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app79/HelloController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test") + public String echo(@RequestParam Optional text) { + return text.orElse("not-specified"); + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app79/SpringDocApp79Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app79/SpringDocApp79Test.java new file mode 100644 index 000000000..4a9834fe5 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app79/SpringDocApp79Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +public class SpringDocApp79Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app8/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app8/HelloController.java new file mode 100644 index 000000000..dcaf48cb9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app8/HelloController.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping("/test") + public void test(String hello) { + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java new file mode 100644 index 000000000..2973929d6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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; + + +public class SpringDocApp8Test extends AbstractSpringDocV30Test { + + @Test + public void testApp() throws Exception { + mockMvc.perform(get("/myapp" + Constants.DEFAULT_API_DOCS_URL).contextPath("/myapp")) + .andExpect(status().isOk()); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app80/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app80/HelloController.java new file mode 100644 index 000000000..bbb03cc0b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app80/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/api") +public class HelloController { + + + @RequestMapping(value = "/testpost1", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity testpost1(@RequestBody TestObject dto) throws URISyntaxException { + return ResponseEntity.ok(dto); + } + + @RequestMapping(value = "/testpost2", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity testpost2(@RequestBody TestObject dto) throws URISyntaxException { + return ResponseEntity.ok(dto); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app80/SpringDocApp80Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app80/SpringDocApp80Test.java new file mode 100644 index 000000000..61376d186 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app80/SpringDocApp80Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; + +@ActiveProfiles("80") +public class SpringDocApp80Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app80/TestObject.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app80/TestObject.java new file mode 100644 index 000000000..8f90ad98f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app80/TestObject.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class TestObject { + public String stringValue; + + public LocalDateTime localDateTime; + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(String stringValue) { + this.stringValue = stringValue; + } + + public LocalDateTime getLocalDateTime() { + return localDateTime; + } + + public void setLocalDateTime(LocalDateTime localDateTime) { + this.localDateTime = localDateTime; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app81/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app81/HelloController.java new file mode 100644 index 000000000..700730dc7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app81/HelloController.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/api") +public class HelloController { + + @RequestMapping + public String test() { + return "ok"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app81/SpringDocApp81Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app81/SpringDocApp81Test.java new file mode 100644 index 000000000..1a0330799 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app81/SpringDocApp81Test.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +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; + +public class SpringDocApp81Test extends AbstractSpringDocV30Test { + + @Test + public 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"))); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app82/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app82/HelloController.java new file mode 100644 index 000000000..edbf3eb68 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app82/HelloController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app82/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app82/PersonDTO.java new file mode 100644 index 000000000..d3d14784f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app82/PersonDTO.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app82/SpringDocApp82Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app82/SpringDocApp82Test.java new file mode 100644 index 000000000..e1695367d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app82/SpringDocApp82Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp82Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app83/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app83/HelloController.java new file mode 100644 index 000000000..a7e0d7f47 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app83/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app83/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app83/PersonDTO.java new file mode 100644 index 000000000..712525b2d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app83/PersonDTO.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app83/SpringDocApp83Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app83/SpringDocApp83Test.java new file mode 100644 index 000000000..9449b8036 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app83/SpringDocApp83Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp83Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app84/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app84/HelloController.java new file mode 100644 index 000000000..e471ba38c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app84/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/api") +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + + @GetMapping("/persons1") + public String persons(String toto) { + return "OK"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app84/SpringDocApp84Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app84/SpringDocApp84Test.java new file mode 100644 index 000000000..3e7660394 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app84/SpringDocApp84Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp84Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app85/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app85/HelloController.java new file mode 100644 index 000000000..73d9e24ff --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app85/HelloController.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/api") +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app85/SpringDocApp85Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app85/SpringDocApp85Test.java new file mode 100644 index 000000000..7753fce97 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app85/SpringDocApp85Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp85Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app86/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app86/HelloController.java new file mode 100644 index 000000000..e9198c6e4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app86/HelloController.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app86/SpringDocApp86Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app86/SpringDocApp86Test.java new file mode 100644 index 000000000..997b6830c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app86/SpringDocApp86Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { + "springdoc.packagesToScan=test.org.springdoc.api.v30.app86", + "springdoc.packagesToExclude=test.org.springdoc.api.v30.app86.test" }) +public class SpringDocApp86Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app86/test/HelloController2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app86/test/HelloController2.java new file mode 100644 index 000000000..f16958637 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app86/test/HelloController2.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController2 { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app87/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app87/HelloController.java new file mode 100644 index 000000000..b423ffa4e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app87/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + + +@RestController("cookie") +public class HelloController { + + @PutMapping("/{itemId}") + @Operation + public ResponseEntity putItem( + @CookieValue( + name = "cookie" + ) String cookie, + @PathVariable UUID itemId, + @RequestBody Item item + ) { + return ResponseEntity.ok(item); + } + + public static class Item { + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app87/SpringDocApp87Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app87/SpringDocApp87Test.java new file mode 100644 index 000000000..02b4e5f57 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app87/SpringDocApp87Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp87Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app88/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app88/HelloController.java new file mode 100644 index 000000000..e7b649dad --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app88/HelloController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping(value = "/persons") + public String persons() { + return null; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app88/SpringDocApp88Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app88/SpringDocApp88Test.java new file mode 100644 index 000000000..7d30b06ff --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app88/SpringDocApp88Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.auto-tag-classes=false") +public class SpringDocApp88Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app89/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app89/HelloController.java new file mode 100644 index 000000000..3054dfe9d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app89/HelloController.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @Operation(summary = "Get Status") + @GetMapping(value = "/status", produces = MediaType.TEXT_HTML_VALUE) + public ModelAndView getAddress(@PathVariable String id) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app89/SpringDocApp89Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app89/SpringDocApp89Test.java new file mode 100644 index 000000000..2c13cb843 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app89/SpringDocApp89Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.servlet.ModelAndView; + +import static org.springdoc.core.SpringDocUtils.getConfig; + +@TestPropertySource(properties = "springdoc.model-and-view-allowed=true") +public class SpringDocApp89Test extends AbstractSpringDocV30Test { + + static { + getConfig().replaceWithSchema(ModelAndView.class, new ObjectSchema()); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app9/MyApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app9/MyApi.java new file mode 100644 index 000000000..900a72e62 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app9/MyApi.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RequestMapping("/myapi") +public interface MyApi { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app9/MyApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app9/MyApiController.java new file mode 100644 index 000000000..d516227f8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app9/MyApiController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class MyApiController implements MyApi { + public String get(String language) { + return language; + } + + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java new file mode 100644 index 000000000..5b0d9bd95 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp9Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app90/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app90/HelloController.java new file mode 100644 index 000000000..91b431294 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app90/HelloController.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @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) { + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app90/SpringDocApp90Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app90/SpringDocApp90Test.java new file mode 100644 index 000000000..a7163daeb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app90/SpringDocApp90Test.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +public class SpringDocApp90Test extends AbstractSpringDocV30Test { + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app90/SpringDocTestApp.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app90/SpringDocTestApp.java new file mode 100644 index 000000000..85711c0f9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app90/SpringDocTestApp.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; +import java.util.Map.Entry; + +import io.swagger.v3.oas.models.examples.Example; +import org.springdoc.core.customizers.OpenApiCustomiser; + +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; + +@SpringBootApplication +class SpringDocTestApp { + + @Value("classpath:/500-90.txt") + private Resource http500ExampleResource; + + public static String asString(Resource resource) { + try (Reader reader = new InputStreamReader(resource.getInputStream())) { + return FileCopyUtils.copyToString(reader); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + @Bean + public OpenApiCustomiser openApiCustomiser(Collection> examples) { + return openAPI -> { + examples.forEach(example -> { + openAPI.getComponents().addExamples(example.getKey(), example.getValue()); + }); + }; + } + + @Bean + public Map.Entry http500Example() { + Example http500Example = new Example(); + Map.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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app90/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app90/User.java new file mode 100644 index 000000000..eaf088223 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app90/User.java @@ -0,0 +1,315 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 + */ + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-11-30T09:49:26.034469-01:00[Atlantic/Azores]") + + +public class User { + + @JsonProperty("id") + + private Long id; + + + @JsonProperty("username") + + private String username; + + + @JsonProperty("firstName") + + private String firstName; + + + @JsonProperty("lastName") + + private String lastName; + + + @JsonProperty("email") + + private String email; + + + @JsonProperty("password") + + private String password; + + + @JsonProperty("phone") + + private String phone; + + + @JsonProperty("userStatus") + + private Integer userStatus; + + + public User id(Long id) { + this.id = id; + return this; + } + + + /** + * Get id + * + * @return id + */ + @Schema(example = "10", description = "") + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + + public User username(String username) { + this.username = username; + return this; + } + + + /** + * Get username + * + * @return username + */ + @Schema(example = "theUser", description = "") + + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + + /** + * Get firstName + * + * @return firstName + */ + @Schema(example = "John", description = "") + + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + + /** + * Get lastName + * + * @return lastName + */ + @Schema(example = "James", description = "") + + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + + public User email(String email) { + this.email = email; + return this; + } + + + /** + * Get email + * + * @return email + */ + @Schema(example = "john@email.com", description = "") + + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + + public User password(String password) { + this.password = password; + return this; + } + + + /** + * Get password + * + * @return password + */ + @Schema(example = "12345", description = "") + + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + + public User phone(String phone) { + this.phone = phone; + return this; + } + + + /** + * Get phone + * + * @return phone + */ + @Schema(example = "12345", description = "") + + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + + /** + * User Status + * + * @return userStatus + */ + @Schema(example = "1", description = "User Status") + + + public Integer getUserStatus() { + return userStatus; + } + + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + @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). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/Advice.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/Advice.java new file mode 100644 index 000000000..206c1c731 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/Advice.java @@ -0,0 +1,90 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.servlet.http.HttpServletRequest; + +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.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; + +@RestControllerAdvice +public class Advice { + + @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); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/ApiError.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/ApiError.java new file mode 100644 index 000000000..fd2cc95bf --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/ApiError.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Schema( + type = "object", + name = "ApiError", + title = "ApiError", + description = "A consistent response object for sending errors over the wire.") +public class ApiError { + + @Schema(name = "status", description = "The Http Status value", type = "int", nullable = true) + @JsonProperty("status") + private int status; + + @Schema( + name = "errorCode", + description = "An Error Code which can help with identifying issues.", + type = "string", + nullable = true) + @JsonProperty("errorCode") + private String errorCode; + + @Schema(name = "message", description = "The Error Message.", type = "string", nullable = false) + @JsonProperty("message") + private String message; + + public ApiError(int status, String errorCode, String message) { + this.status = status; + this.errorCode = errorCode; + this.message = message; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/Greeting.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/Greeting.java new file mode 100644 index 000000000..3167d511b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/Greeting.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Schema( + type = "object", + name = "Greeting", + title = "Greeting", + description = "An object containing a greeting message") +public class Greeting { + + + @Schema( + name = "payload", + description = "The greeting value", + type = "string", + nullable = false, + example = "sdfsdfs") + @JsonProperty("payload") + private String payload; + + public Greeting(String payload) { + this.payload = payload; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/GreetingController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/GreetingController.java new file mode 100644 index 000000000..e1532341f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/GreetingController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@Tag(name = "Demo", description = "The Demo API") +public class GreetingController { + + @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))); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/SpringDocApp91Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/SpringDocApp91Test.java new file mode 100644 index 000000000..d21b79c67 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app91/SpringDocApp91Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.override-with-generic-response=false") +public class SpringDocApp91Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app92/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app92/HelloController.java new file mode 100644 index 000000000..0343d0c35 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app92/HelloController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotNull; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/test") +public class HelloController { + + @GetMapping + String index(@NotNull String test) { + return null; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app92/ParameterCustomizer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app92/ParameterCustomizer.java new file mode 100644 index 000000000..115abf1b0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app92/ParameterCustomizer.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotNull; + +import io.swagger.v3.oas.models.parameters.Parameter; + +import org.springframework.core.MethodParameter; +import org.springframework.stereotype.Component; + +@Component +public class ParameterCustomizer implements org.springdoc.core.customizers.ParameterCustomizer { + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app92/SpringDocApp92Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app92/SpringDocApp92Test.java new file mode 100644 index 000000000..1d4d0cd9d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app92/SpringDocApp92Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp92Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/BaseClientModel.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/BaseClientModel.java new file mode 100644 index 000000000..d55bcf73f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/BaseClientModel.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public abstract class BaseClientModel { + @JsonProperty("id") + int id; +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/BaseController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/BaseController.java new file mode 100644 index 000000000..6432ef4ee --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/BaseController.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public abstract class BaseController { + @Operation + @GetMapping + TClientModel get(TClientModel param) { + return null; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/SpecificClientModel.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/SpecificClientModel.java new file mode 100644 index 000000000..adf3db566 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/SpecificClientModel.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class SpecificClientModel extends BaseClientModel { + @JsonProperty("name") + String name; +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/SpecificController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/SpecificController.java new file mode 100644 index 000000000..d43abea73 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/SpecificController.java @@ -0,0 +1,28 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class SpecificController extends BaseController {} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/SpringDocApp93Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/SpringDocApp93Test.java new file mode 100644 index 000000000..5b51a588e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app93/SpringDocApp93Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp93Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app94/SpringDocApp94Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app94/SpringDocApp94Test.java similarity index 83% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app94/SpringDocApp94Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app94/SpringDocApp94Test.java index e4f43875f..35944807e 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app94/SpringDocApp94Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app94/SpringDocApp94Test.java @@ -1,23 +1,27 @@ -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 + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * See the License for the specific language governing permissions and + * * * * limitations under the License. + * * * * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 java.util.List; import java.util.Optional; @@ -38,8 +42,8 @@ import org.springdoc.core.customizers.OperationCustomizer; import org.springdoc.core.filters.OpenApiMethodFilter; import org.springdoc.webmvc.api.OpenApiWebMvcResource; -import test.org.springdoc.api.AbstractSpringDocTest; -import test.org.springdoc.api.app91.Greeting; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; +import test.org.springdoc.api.v30.app91.Greeting; import org.springframework.beans.BeansException; import org.springframework.beans.factory.ObjectFactory; @@ -60,7 +64,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @TestPropertySource(properties = "springdoc.default-produces-media-type=application/json") -public class SpringDocApp94Test extends AbstractSpringDocTest { +public class SpringDocApp94Test extends AbstractSpringDocV30Test { @SpringBootApplication static class SpringDocTestApp implements ApplicationContextAware { diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app95/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app95/HelloController.java new file mode 100644 index 000000000..9b42bfc53 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app95/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/persons") +public class HelloController { + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v30/app95/SpringDocApp95Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app95/SpringDocApp95Test.java new file mode 100644 index 000000000..14e7c5c52 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app95/SpringDocApp95Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; + +@ActiveProfiles("95") +public class SpringDocApp95Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app96/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app96/HelloController.java new file mode 100644 index 000000000..9f7d3f809 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app96/HelloController.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +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("/api1") + String test1(@RequestBody @Min(2) int test) { + return null; + } + + @PostMapping("/api2") + String test2(@RequestBody String test) { + return null; + } + + @PostMapping("/api3") + String test3(@NotNull String test) { + return null; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app96/SpringDocApp96Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app96/SpringDocApp96Test.java new file mode 100644 index 000000000..178d595d6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app96/SpringDocApp96Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp96Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/HelloController.java new file mode 100644 index 000000000..7144dc417 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/api") +public class HelloController { + + @GetMapping(value = "/student/header1", headers = "X-API-VERSION=1") + public StudentV1 headerV1() { + return new StudentV1("Bob Charlie"); + } + + @GetMapping(value = "/student/header2", headers = "X-API-VERSION=2") + public StudentV2 headerV2() { + return new StudentV2("Charlie"); + } + + @GetMapping(value = "/student/header3", headers = "X-API-VERSION") + public StudentV3 headerV3() { + return new StudentV3("Tom Charlie"); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/SpringDocApp97Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/SpringDocApp97Test.java new file mode 100644 index 000000000..9885d917c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/SpringDocApp97Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp97Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/StudentV1.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/StudentV1.java new file mode 100644 index 000000000..e09b36b1e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/StudentV1.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class StudentV1 { + + @JsonProperty("name") + private String name; + + public StudentV1(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/StudentV2.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/StudentV2.java new file mode 100644 index 000000000..13037b26d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/StudentV2.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class StudentV2 { + + @JsonProperty("name") + private String name; + + public StudentV2(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/StudentV3.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/StudentV3.java new file mode 100644 index 000000000..f7b71c242 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app97/StudentV3.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class StudentV3 { + + @JsonProperty("name") + private String name; + + public StudentV3(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app98/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app98/HelloController.java new file mode 100644 index 000000000..c9111f7f7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app98/HelloController.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public void persons(@IgnoredAnnotationParameter String name) { + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app98/IgnoredAnnotationParameter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app98/IgnoredAnnotationParameter.java new file mode 100644 index 000000000..e73b8ad67 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app98/IgnoredAnnotationParameter.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Retention(RetentionPolicy.RUNTIME) +public @interface IgnoredAnnotationParameter { + String addition() default "customized parameter!"; +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app98/SpringDocApp98Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app98/SpringDocApp98Test.java new file mode 100644 index 000000000..6c7757de0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app98/SpringDocApp98Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.SpringDocUtils; +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp98Test extends AbstractSpringDocV30Test { + + static { + SpringDocUtils.getConfig().addAnnotationsToIgnore(IgnoredAnnotationParameter.class); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app99/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app99/HelloController.java new file mode 100644 index 000000000..261cb8ff8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app99/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@RequestMapping("/persons") +public class HelloController { + + @GetMapping + @ApiResponses({ + @ApiResponse(responseCode = "202", description = "${test.app99.operation.persons.response.202.description}") + }) + public void persons() { + + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app99/SpringDocApp99Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app99/SpringDocApp99Test.java new file mode 100644 index 000000000..47ac5bc81 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app99/SpringDocApp99Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; + +@ActiveProfiles("99") +public class SpringDocApp99Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocActuatorV31Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocActuatorV31Test.java new file mode 100644 index 000000000..d7a115d70 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocActuatorV31Test.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.annotation.PostConstruct; + +import test.org.springdoc.api.AbstractCommonTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.client.RestTemplate; + +@TestPropertySource(properties={ "management.endpoints.enabled-by-default=true", "springdoc.api-docs.version=openapi_3_1" }) +public abstract class AbstractSpringDocActuatorV31Test extends AbstractCommonTest { + + @LocalManagementPort + private int managementPort; + + @Autowired + private RestTemplateBuilder restTemplateBuilder; + + protected RestTemplate actuatorRestTemplate; + + @PostConstruct + void init() { + actuatorRestTemplate = restTemplateBuilder + .rootUri("http://localhost:" + this.managementPort).build(); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocV31Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocV31Test.java new file mode 100644 index 000000000..e8c6292b3 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocV31Test.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.Constants; +import test.org.springdoc.api.AbstractCommonTest; + +import org.springframework.boot.test.context.SpringBootTest; +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; + +@SpringBootTest +@TestPropertySource(properties = {"springdoc.api-docs.version=openapi_3_1"}) +public abstract class AbstractSpringDocV31Test extends AbstractCommonTest { + + public static String className; + + @Test + public 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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ApiException.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ApiException.java new file mode 100644 index 000000000..f9e28f902 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ApiException.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 final class ApiException extends Exception { + + private static final long serialVersionUID = 1L; + + @SuppressWarnings("unused") + + private final int code; + + public ApiException(int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ApiOriginFilter.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ApiOriginFilter.java new file mode 100644 index 000000000..c9abd5ddb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ApiOriginFilter.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletResponse; + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +public class ApiOriginFilter implements javax.servlet.Filter { + @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); + } + + @Override + public void destroy() { + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ApiResponseMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ApiResponseMessage.java new file mode 100644 index 000000000..b7100e4c2 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ApiResponseMessage.java @@ -0,0 +1,98 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.xml.bind.annotation.XmlTransient; + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +@javax.xml.bind.annotation.XmlRootElement +public class ApiResponseMessage { + public static final int ERROR = 1; + + public static final int WARNING = 2; + + public static final int INFO = 3; + + public static final int OK = 4; + + public static final int TOO_BUSY = 5; + + int code; + + String type; + + String message; + + public ApiResponseMessage() { + } + + 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; + } + + @XmlTransient + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ErrorMessage.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ErrorMessage.java new file mode 100644 index 000000000..ed18a18dd --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ErrorMessage.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 ErrorMessage { + + private String id; + + private String message; + + public ErrorMessage(String id, String message2) { + this.id = id; + this.message = message2; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ExceptionTranslator.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ExceptionTranslator.java new file mode 100644 index 000000000..6bce1233c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ExceptionTranslator.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@ControllerAdvice +public class ExceptionTranslator { + + private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionTranslator.class); + + @ExceptionHandler({ RuntimeException.class }) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity handleRunTimeException(RuntimeException e) { + return error(HttpStatus.INTERNAL_SERVER_ERROR, e); + } + + + 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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/HelloController.java new file mode 100644 index 000000000..f02cd9e90 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @GetMapping(value = "/hello/{numTelco}") + @ResponseStatus(HttpStatus.I_AM_A_TEAPOT) + @Tag(name = "${prop.toto}") + 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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/HomeController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/HomeController.java new file mode 100644 index 000000000..795aa261a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/HomeController.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/InventoryApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/InventoryApi.java new file mode 100644 index 000000000..62eece6e9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/InventoryApi.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +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 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; + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +@Tag(name = "inventory") +public interface InventoryApi { + + @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); + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/InventoryApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/InventoryApiController.java new file mode 100644 index 000000000..b4f54f53b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/InventoryApiController.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.v3.oas.annotations.Parameter; + +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; + +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +@RestController +public class InventoryApiController implements InventoryApi { + + + @SuppressWarnings("unused") + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public InventoryApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + 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); + } + + 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); + } + + public String getme(String language) { + return language; + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/InventoryItem.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/InventoryItem.java new file mode 100644 index 000000000..b52f7bbc9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/InventoryItem.java @@ -0,0 +1,184 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.NotNull; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.validation.annotation.Validated; + +/** + * InventoryItem + */ +@Validated +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +public class InventoryItem { + @JsonProperty("id") + private UUID id = null; + + @JsonProperty("name") + private String name = null; + + @JsonProperty("releaseDate") + private String releaseDate = null; + + @JsonProperty("manufacturer") + private Manufacturer manufacturer = null; + + public InventoryItem id(UUID id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + **/ + @Schema(example = "d290f1ee-6c54-4b01-90e6-d701748f0851", required = true) + @NotNull + + @Valid + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public InventoryItem name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name + **/ + @Schema(example = "Widget Adapter", required = true) + @NotNull + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public InventoryItem releaseDate(String releaseDate) { + this.releaseDate = releaseDate; + return this; + } + + /** + * Get releaseDate + * + * @return releaseDate + **/ + @Schema(example = "2016-08-29T09:12:33.001Z", required = true) + @NotNull + + public String getReleaseDate() { + return releaseDate; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public InventoryItem manufacturer(Manufacturer manufacturer) { + this.manufacturer = manufacturer; + return this; + } + + /** + * Get manufacturer + * + * @return manufacturer + **/ + @Schema(required = true) + @NotNull + + @Valid + public Manufacturer getManufacturer() { + return manufacturer; + } + + public void setManufacturer(Manufacturer manufacturer) { + this.manufacturer = manufacturer; + } + + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, releaseDate, manufacturer); + } + + @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). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ItemController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ItemController.java new file mode 100644 index 000000000..42270a6cc --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ItemController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.Valid; +import javax.validation.constraints.Size; + +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 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; + +@RestController +@Tag(name = "items") +public class ItemController { + + @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(); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ItemDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ItemDTO.java new file mode 100644 index 000000000..0d45893be --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ItemDTO.java @@ -0,0 +1,130 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +/** + * @author bnasslahsen + */ +public 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; + + @Deprecated + private int deprecatedPrice; + + /** + * + */ + public ItemDTO() { + } + + /** + * @param description description + * @param price price + */ + public ItemDTO(final String description, final int price) { + this.description = description; + this.price = price; + } + + /** + * @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; + } + + /** + * @return + */ + public String getDescription() { + return description; + } + + /** + * @param description description + */ + public void setDescription(final String description) { + this.description = description; + } + + /** + * @return + */ + public String getItemID() { + return itemID; + } + + /** + * @param itemID itemID + */ + public void setItemID(final String itemID) { + this.itemID = itemID; + } + + /** + * @return + */ + public int getPrice() { + return price; + } + + /** + * @param price price + */ + public void setPrice(final int price) { + this.price = price; + } + + public int getDeprecatedPrice() { + return deprecatedPrice; + } + + public void setDeprecatedPrice(int deprecatedPrice) { + this.deprecatedPrice = deprecatedPrice; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ItemLightDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ItemLightDTO.java new file mode 100644 index 000000000..e066712a9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/ItemLightDTO.java @@ -0,0 +1,97 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +/** + * @author bnasslahsen + */ +public 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; + + @Deprecated + private int deprecatedPrice; + + /** + * + */ + public ItemLightDTO() { + } + + public ItemLightDTO(String description, int price) { + super(); + this.description = description; + this.price = price; + } + + /** + * @return + */ + public String getDescription() { + return description; + } + + /** + * @param description description + */ + public void setDescription(final String description) { + this.description = description; + } + + /** + * @return + */ + public int getPrice() { + return price; + } + + /** + * @param price price + */ + public void setPrice(final int price) { + this.price = price; + } + + public int getDeprecatedPrice() { + return deprecatedPrice; + } + + public void setDeprecatedPrice(int deprecatedPrice) { + this.deprecatedPrice = deprecatedPrice; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/Manufacturer.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/Manufacturer.java new file mode 100644 index 000000000..c558545ad --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/Manufacturer.java @@ -0,0 +1,152 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotNull; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.validation.annotation.Validated; + + +/** + * Manufacturer + */ +@Validated +@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +public class Manufacturer { + @JsonProperty("name") + private String name = null; + + @JsonProperty("homePage") + private String homePage = null; + + @JsonProperty("phone") + private String phone = null; + + public Manufacturer name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name + **/ + @Schema(example = "ACME Corporation", required = true) + @NotNull + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Manufacturer homePage(String homePage) { + this.homePage = homePage; + return this; + } + + /** + * Get homePage + * + * @return homePage + **/ + @Schema(example = "https://www.acme-corp.com") + + public String getHomePage() { + return homePage; + } + + public void setHomePage(String homePage) { + this.homePage = homePage; + } + + public Manufacturer phone(String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * + * @return phone + **/ + @Schema(example = "408-867-5309") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + + @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); + } + + @Override + public int hashCode() { + return Objects.hash(name, homePage, phone); + } + + @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). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/PeopleRestService.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/PeopleRestService.java new file mode 100644 index 000000000..234876951 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/PeopleRestService.java @@ -0,0 +1,111 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +@Tag(name = "people") +public class PeopleRestService { + private Map people = new ConcurrentHashMap<>(); + + @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(); + } + + @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; + } + + @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(); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/PersonDTO.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/PersonDTO.java new file mode 100644 index 000000000..9b9651edf --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/PersonDTO.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java new file mode 100644 index 000000000..645801e3c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV31Test; + +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 { + + @SpringBootApplication + 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("SpringShop API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java new file mode 100644 index 000000000..4c93c2eeb --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV31Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp2Test extends AbstractSpringDocV31Test { + + @SpringBootApplication + 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("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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/ApiUtil.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/ApiUtil.java new file mode 100644 index 000000000..a56adda93 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/ApiUtil.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/ExceptionTranslator.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/ExceptionTranslator.java new file mode 100644 index 000000000..a001480cf --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/ExceptionTranslator.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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("javax.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); + return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/HomeController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/HomeController.java new file mode 100644 index 000000000..90deb5f1d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/HomeController.java @@ -0,0 +1,46 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/PetApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/PetApi.java new file mode 100644 index 000000000..b4d2e1017 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/PetApi.java @@ -0,0 +1,166 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.NotNull; + +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 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; + +@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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiController.java new file mode 100644 index 000000000..af05b0fa0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@javax.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:/}") +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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiDelegate.java new file mode 100644 index 000000000..3879558f7 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiDelegate.java @@ -0,0 +1,145 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.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. + */ +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiDelegateImpl.java new file mode 100644 index 000000000..0cf27890a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiDelegateImpl.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Service +public class PetApiDelegateImpl implements PetApiDelegate { + + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApi.java new file mode 100644 index 000000000..6d9ae191c --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApi.java @@ -0,0 +1,109 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +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 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; + +@javax.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}") + @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); + } + + @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(); + } + + @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); + } + + @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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiController.java new file mode 100644 index 000000000..0b9172fc9 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@javax.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:/}") +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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiDelegate.java new file mode 100644 index 000000000..be7c9877b --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiDelegate.java @@ -0,0 +1,96 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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. + */ +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiDelegateImpl.java new file mode 100644 index 000000000..386e009d4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiDelegateImpl.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Service +public class StoreApiDelegateImpl implements StoreApiDelegate { + + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/UserApi.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/UserApi.java new file mode 100644 index 000000000..1bdb8241e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/UserApi.java @@ -0,0 +1,137 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT 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 javax.validation.Valid; +import javax.validation.constraints.NotNull; + +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 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; + +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiController.java new file mode 100644 index 000000000..67574959a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@javax.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:/}") +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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiDelegate.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiDelegate.java new file mode 100644 index 000000000..f713954ae --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiDelegate.java @@ -0,0 +1,125 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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. + */ +@javax.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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiDelegateImpl.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiDelegateImpl.java new file mode 100644 index 000000000..87ca95ec4 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiDelegateImpl.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@Service +public class UserApiDelegateImpl implements UserApiDelegate { + + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Body.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Body.java new file mode 100644 index 000000000..d3c7eba3a --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Body.java @@ -0,0 +1,101 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Body1.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Body1.java new file mode 100644 index 000000000..cc2cf64bc --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Body1.java @@ -0,0 +1,103 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Category.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Category.java new file mode 100644 index 000000000..d5b088052 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Category.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/ModelApiResponse.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/ModelApiResponse.java new file mode 100644 index 000000000..7b7c67099 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/ModelApiResponse.java @@ -0,0 +1,118 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Order.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Order.java new file mode 100644 index 000000000..e6e508334 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Order.java @@ -0,0 +1,230 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Pet.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Pet.java new file mode 100644 index 000000000..62bdc0db8 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Pet.java @@ -0,0 +1,245 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 javax.validation.constraints.NotNull; + +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 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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Tag.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Tag.java new file mode 100644 index 000000000..3a0a2704d --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/Tag.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/User.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/User.java new file mode 100644 index 000000000..10aa9715e --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app2/model/User.java @@ -0,0 +1,236 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +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-webmvc-core/src/test/java/test/org/springdoc/api/v31/app4/HelloController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app4/HelloController.java new file mode 100644 index 000000000..0e7a8b017 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app4/HelloController.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +@RestController +public class HelloController { + + @PostMapping(value = "/values/data") + TrackerData list(TrackerData toto) { + return toto; + + } + +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java new file mode 100644 index 000000000..cfc085544 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.AbstractSpringDocV31Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.use-fqn=true") +public class SpringDocApp4Test extends AbstractSpringDocV31Test { + + @SpringBootApplication + static class SpringDocTestApp {} + + @AfterAll + static void restore(){ + TypeNameResolver.std.setUseFqn(false); + } +} \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app4/TrackerData.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app4/TrackerData.java new file mode 100644 index 000000000..9ae6c8dd6 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app4/TrackerData.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2022 the original author or authors. + * * * * + * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * you may not use this file except in compliance with the License. + * * * * You may obtain a copy of the License at + * * * * + * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * + * * * * Unless required by applicable law or agreed to in writing, software + * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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; + +public class TrackerData { + + @Schema(name = "trackerId", type = "string", required = true, example = "the-tracker-id") + @JsonProperty("trackerId") + String trackerId; + + @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") + @JsonProperty("timestamp") + Instant timestamp; + + @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-webmvc-core/src/test/resources/results/app1.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app1.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app1.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app1.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app10.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app10.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app10.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app10.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app100.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app100.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app100.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app100.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app101.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app101.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app101.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app101.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app102.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app102.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app102.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app102.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app103.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app103.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app103.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app103.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app104.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app104.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app104.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app104.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app105-1.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app105-1.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app105-1.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app105-1.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app105-2.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app105-2.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app105-2.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app105-2.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app105-3.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app105-3.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app105-3.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app105-3.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app105-4.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app105-4.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app105-4.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app105-4.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app106.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app106.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app106.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app106.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app107.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app107.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app107.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app107.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app108.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app108.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app108.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app108.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app109.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app109.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app109.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app109.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app11.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app11.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app11.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app11.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app110.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app110.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app110.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app110.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app111.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app111.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app111.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app111.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app112.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app112.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app112.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app112.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app113.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app113.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app113.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app113.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app114.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app114.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app114.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app114.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app115.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app115.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app115.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app115.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app116.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app116.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app116.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app116.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app117.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app117.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app117.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app117.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app118.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app118.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app118.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app118.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app119.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app119.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app119.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app119.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app12.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app12.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app12.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app12.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app120.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app120.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app120.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app120.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app121.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app121.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app121.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app121.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app122.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app122.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app122.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app122.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app123.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app123.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app123.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app123.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app124.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app124.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app124.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app124.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app125.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app125.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app125.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app125.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app126.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app126.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app126.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app126.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app128.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app128.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app128.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app128.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app129.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app129.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app129.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app129.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app13.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app13.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app13.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app13.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app130.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app130.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app130.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app130.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app131.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app131.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app131.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app131.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app132.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app132.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app132.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app132.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app133.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app133.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app133.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app133.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app134-1.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app134-1.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app134-1.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app134-1.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app134-2.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app134-2.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app134-2.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app134-2.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app134-3.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app134-3.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app134-3.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app134-3.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app134-4.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app134-4.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app134-4.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app134-4.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app134-5.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app134-5.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app134-5.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app134-5.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app135.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app135.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app135.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app135.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app136.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app136.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app136.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app136.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app137.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app137.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app137.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app137.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app138.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app138.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app138.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app138.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app139.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app139.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app139.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app139.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app14.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app14.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app14.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app14.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app140.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app140.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app140.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app140.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app141.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app141.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app141.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app141.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app142.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app142.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app142.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app142.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app143.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app143.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app143.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app143.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app144.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app144.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app144.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app144.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app145.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app145.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app145.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app145.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app146-1.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app146-1.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app146-1.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app146-1.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app146-2.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app146-2.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app146-2.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app146-2.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app147-1.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app147-1.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app147-1.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app147-1.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app147-2.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app147-2.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app147-2.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app147-2.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app148-1.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app148-1.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app148-1.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app148-1.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app148-2.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app148-2.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app148-2.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app148-2.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app149.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app149.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app149.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app149.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app15.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app15.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app15.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app15.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app150.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app150.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app150.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app150.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app151.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app151.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app151.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app151.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app152.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app152.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app152.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app152.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app153.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app153.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app153.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app153.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app154.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app154.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app154.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app154.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app155.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app155.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app155.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app155.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app156.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app156.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app156.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app156.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app157.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app157.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app157.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app157.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app158.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app158.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app158.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app158.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app159.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app159.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app159.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app159.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app160-1.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app160-1.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app160-1.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app160-1.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app160.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app160.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app160.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app160.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app161.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app161.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app161.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app161.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app162.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app162.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app162.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app162.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app163.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app163.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app163.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app163.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app164.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app164.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app164.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app164.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app165.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app165.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app165.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app165.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app166.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app166.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app166.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app166.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app167.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app167.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app167.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app167.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app168.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app168.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app168.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app168.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app169.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app169.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app169.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app169.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app17.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app17.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app17.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app17.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app170.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app170.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app170.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app170.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app171-en-GB.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app171-en-GB.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app171-en-GB.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app171-en-GB.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app171-en-US.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app171-en-US.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app171-en-US.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app171-en-US.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app171-fr-FR.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app171-fr-FR.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app171-fr-FR.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app171-fr-FR.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app172.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app172.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app172.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app172.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app173.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app173.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app173.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app173.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app174.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app174.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app174.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app174.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app175.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app175.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app175.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app175.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app176.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app176.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app176.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app176.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app177-1.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app177-1.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app177-1.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app177-1.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app177-2.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app177-2.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app177-2.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app177-2.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app177-3.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app177-3.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app177-3.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app177-3.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app177.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app177.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app177.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app177.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app178-1.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app178-1.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app178-1.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app178-1.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app178-2.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app178-2.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app178-2.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app178-2.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app178-3.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app178-3.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app178-3.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app178-3.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app178.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app178.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app178.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app178.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app179.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app179.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app179.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app179.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app18.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app18.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app18.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app18.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app180.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app180.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app180.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app180.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app181.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app181.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app181.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app181.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app182.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app182.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app182.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app182.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app183.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app183.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app183.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app183.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app184-1.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app184-1.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app184-1.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app184-1.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app184-2.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app184-2.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app184-2.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app184-2.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app184-3.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app184-3.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app184-3.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app184-3.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app184.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app184.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app184.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app184.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app185.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app185.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app185.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app185.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app19.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app19.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app19.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app19.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app2.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app2.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app2.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app2.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app20.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app20.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app20.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app20.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app21.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app21.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app21.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app21.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app22.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app22.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app22.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app22.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app23.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app23.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app23.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app23.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app24.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app24.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app24.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app24.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app25.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app25.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app25.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app25.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app26.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app26.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app26.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app26.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app27.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app27.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app27.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app27.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app28.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app28.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app28.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app28.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app29.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app29.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app29.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app29.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app30.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app30.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app30.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app30.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app31.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app31.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app31.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app31.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app32.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app32.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app32.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app32.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app33.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app33.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app33.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app33.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app34.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app34.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app34.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app34.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app35.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app35.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app35.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app35.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app36.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app36.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app36.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app36.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app37.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app37.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app37.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app37.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app38.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app38.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app38.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app38.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app39.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app39.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app39.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app39.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app4.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app4.json new file mode 100644 index 000000000..8aa24f233 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app4.json @@ -0,0 +1,74 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/values/data": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "list", + "parameters": [ + { + "name": "toto", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v30.app4.TrackerData" + } + } + ], + "responses": { + "200": { + "description": "OK", + "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", + "example": "the-tracker-id" + }, + "timestamp": { + "type": "string", + "format": "date-time", + "example": "2018-01-01T00:00:00Z" + }, + "value": { + "type": "number", + "description": "The data value", + "format": "double", + "example": 19.0 + } + } + } + } + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app40.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app40.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app40.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app40.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app41.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app41.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app41.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app41.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app42.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app42.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app42.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app42.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app43.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app43.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app43.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app43.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app44.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app44.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app44.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app44.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app45.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app45.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app45.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app45.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app46.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app46.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app46.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app46.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app47.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app47.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app47.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app47.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app48.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app48.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app48.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app48.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app49.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app49.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app49.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app49.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app50.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app50.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app50.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app50.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app51.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app51.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app51.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app51.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app52.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app52.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app52.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app52.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app53.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app53.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app53.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app53.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app54.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app54.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app54.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app54.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app55.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app55.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app55.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app55.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app56.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app56.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app56.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app56.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app57.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app57.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app57.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app57.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app58.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app58.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app58.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app58.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app59.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app59.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app59.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app59.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app6.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app6.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app6.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app6.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app60.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app60.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app60.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app60.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app61.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app61.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app61.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app61.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app62.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app62.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app62.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app62.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app63.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app63.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app63.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app63.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app64.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app64.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app64.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app64.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app65.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app65.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app65.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app65.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app66.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app66.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app66.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app66.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app67.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app67.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app67.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app67.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app68-1.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app68-1.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app68-1.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app68-1.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app68-2.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app68-2.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app68-2.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app68-2.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app68-3.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app68-3.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app68-3.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app68-3.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app68-4.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app68-4.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app68-4.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app68-4.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app69.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app69.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app69.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app69.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app7.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app7.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app7.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app7.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app70.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app70.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app70.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app70.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app71.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app71.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app71.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app71.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app73.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app73.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app73.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app73.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app74.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app74.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app74.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app74.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app75.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app75.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app75.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app75.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app76.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app76.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app76.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app76.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app77.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app77.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app77.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app77.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app78.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app78.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app78.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app78.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app79.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app79.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app79.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app79.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app8.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app8.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app8.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app8.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app80.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app80.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app80.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app80.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app82.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app82.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app82.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app82.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app83.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app83.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app83.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app83.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app84.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app84.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app84.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app84.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app85.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app85.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app85.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app85.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app86.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app86.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app86.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app86.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app87.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app87.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app87.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app87.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app88.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app88.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app88.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app88.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app89.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app89.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app89.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app89.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app9.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app9.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app9.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app9.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app90.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app90.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app90.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app90.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app91.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app91.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app91.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app91.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app92.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app92.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app92.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app92.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app93.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app93.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app93.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app93.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app94.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app94.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app94.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app94.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app95.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app95.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app95.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app95.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app96.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app96.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app96.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app96.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app97.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app97.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app97.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app97.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app98.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app98.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app98.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app98.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app99.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app99.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app99.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app99.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/3.1.0/app1.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.1.0/app1.json new file mode 100644 index 000000000..0275059fa --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/resources/results/3.1.0/app1.json @@ -0,0 +1,582 @@ +{ + "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" + } + ], + "tags": [ + { + "name": "inventory" + }, + { + "name": "people" + }, + { + "name": "tea" + }, + { + "name": "items" + } + ], + "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": {} + } + ], + "responses": { + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "OK", + "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": {} + }, + { + "name": "firstName", + "in": "query", + "description": "First Name", + "required": true, + "schema": {} + }, + { + "name": "lastName", + "in": "query", + "description": "Last Name", + "required": true, + "schema": {} + } + ], + "responses": { + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "201": { + "description": "Created", + "headers": { + "Location": { + "style": "simple", + "schema": {} + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + }, + "409": { + "description": "Person with such e-mail already exists", + "content": { + "application/json": { + "schema": {} + } + } + } + } + }, + "delete": { + "tags": [ + "people" + ], + "description": "Delete existing person", + "operationId": "deletePerson", + "parameters": [ + { + "name": "email", + "in": "path", + "description": "E-Mail address to lookup for", + "required": true, + "schema": {} + } + ], + "responses": { + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "204": { + "description": "Person has been deleted", + "content": { + "application/json": { + "schema": {} + } + } + }, + "404": { + "description": "Person with such e-mail doesn't exists", + "content": { + "application/json": { + "schema": {} + } + } + } + } + } + }, + "/items": { + "get": { + "tags": [ + "items" + ], + "operationId": "showItems", + "parameters": [ + { + "name": "cusID", + "in": "query", + "required": true, + "schema": { + "maxLength": 6, + "minLength": 4 + } + }, + { + "name": "toto", + "in": "query", + "required": true, + "schema": { + "format": "int32", + "maximum": 6, + "minimum": 4 + } + }, + { + "name": "start", + "in": "query", + "required": false, + "schema": { + "format": "date-time", + "example": "1970-01-01T00:00:00.000Z" + } + }, + { + "name": "filterIds", + "in": "query", + "required": false, + "explode": false, + "schema": { + "items": {} + } + } + ], + "responses": { + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/ItemDTO" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "items" + ], + "operationId": "addItem", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ItemLightDTO" + } + } + }, + "required": true + }, + "responses": { + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "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": {} + }, + { + "name": "skip", + "in": "query", + "description": "number of records to skip for pagination", + "required": true, + "schema": { + "format": "int32", + "minimum": 0 + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of records to return", + "required": true, + "schema": { + "format": "int32", + "maximum": 50, + "minimum": 0 + } + } + ], + "responses": { + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "search results matching criteria", + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/InventoryItem" + } + } + } + } + }, + "400": { + "description": "bad input parameter", + "content": { + "application/json": { + "schema": { + "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": "Internal Server Error", + "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": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + }, + "/hello/{numTelco}": { + "get": { + "tags": [ + "tea" + ], + "operationId": "index", + "parameters": [ + { + "name": "numTelco", + "in": "path", + "required": true, + "schema": {} + }, + { + "name": "adresse", + "in": "query", + "required": true, + "schema": {} + } + ], + "responses": { + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "418": { + "description": "I'm a teapot", + "content": { + "application/json": { + "schema": {} + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ErrorMessage": { + "properties": { + "id": {}, + "message": {} + } + }, + "PersonDTO": { + "properties": { + "email": {}, + "firstName": {}, + "lastName": {} + } + }, + "ItemLightDTO": { + "properties": { + "description": {}, + "price": { + "format": "int32" + }, + "deprecatedPrice": { + "format": "int32", + "deprecated": true + } + } + }, + "InventoryItem": { + "properties": { + "id": { + "format": "uuid", + "example": "d290f1ee-6c54-4b01-90e6-d701748f0851" + }, + "name": { + "example": "Widget Adapter" + }, + "releaseDate": { + "example": "2016-08-29T09:12:33.001Z" + }, + "manufacturer": { + "$ref": "#/components/schemas/Manufacturer" + } + }, + "required": [ + "id", + "manufacturer", + "name", + "releaseDate" + ] + }, + "Manufacturer": { + "properties": { + "name": { + "example": "ACME Corporation" + }, + "homePage": { + "example": "https://www.acme-corp.com" + }, + "phone": { + "example": "408-867-5309" + } + }, + "required": [ + "name" + ] + }, + "ItemDTO": { + "properties": { + "itemID": {}, + "description": {}, + "price": { + "format": "int32" + }, + "deprecatedPrice": { + "format": "int32", + "deprecated": true + } + } + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + } + } + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/3.1.0/app2.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.1.0/app2.json new file mode 100644 index 000000000..158c799fa --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/resources/results/3.1.0/app2.json @@ -0,0 +1,1104 @@ +{ + "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", + "operationId": "getUserByName", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "The name that needs to be fetched. Use user1 for testing.", + "required": true, + "schema": {} + } + ], + "responses": { + "400": { + "description": "Invalid username supplied", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "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": {} + } + ], + "requestBody": { + "description": "Updated user object", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Invalid user supplied", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "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": {} + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/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": { + "additionalProperties": {} + } + } + } + }, + "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": { + "additionalProperties": {} + } + } + } + }, + "405": { + "description": "Invalid input" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/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": { + "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": { + "items": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "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": { + "items": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/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": { + "additionalProperties": {} + } + } + } + }, + "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": { + "format": "int64" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "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": { + "format": "int64" + } + }, + { + "name": "name", + "in": "query", + "description": "Updated name of the pet", + "required": false, + "schema": {} + }, + { + "name": "status", + "in": "query", + "description": "Updated status of the pet", + "required": false, + "schema": {} + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "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": { + "format": "int64" + } + }, + { + "name": "api_key", + "in": "header", + "required": false, + "schema": {} + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "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": { + "format": "int64" + } + }, + { + "name": "additionalMetadata", + "in": "query", + "description": "Additional data to pass to server", + "required": false, + "schema": {} + } + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "properties": { + "file": { + "format": "binary", + "description": "file detail" + } + }, + "required": [ + "file" + ] + } + } + } + }, + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "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", + "operationId": "logoutUser", + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "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": {} + }, + { + "name": "password", + "in": "query", + "description": "The password for login in clear text", + "required": true, + "schema": {} + } + ], + "responses": { + "400": { + "description": "Invalid username/password supplied", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": {} + }, + "application/json": { + "schema": {} + } + } + } + } + } + }, + "/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": { + "format": "int64", + "maximum": 5, + "minimum": 1 + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "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": {} + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "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": { + "additionalProperties": {} + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "items": {} + } + } + } + } + }, + "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": { + "items": {} + } + } + ], + "responses": { + "400": { + "description": "Invalid tag value", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "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": { + "items": {} + } + } + ], + "responses": { + "400": { + "description": "Invalid status value", + "content": { + "*/*": { + "schema": { + "additionalProperties": {} + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + } + }, + "components": { + "schemas": { + "User": { + "properties": { + "id": { + "format": "int64" + }, + "username": {}, + "firstName": {}, + "lastName": {}, + "email": {}, + "password": {}, + "phone": {}, + "userStatus": { + "format": "int32", + "description": "User Status" + } + } + }, + "Category": { + "properties": { + "id": { + "format": "int64" + }, + "name": {} + } + }, + "Pet": { + "properties": { + "id": { + "format": "int64" + }, + "category": { + "$ref": "#/components/schemas/Category" + }, + "name": { + "example": "doggie" + }, + "photoUrls": { + "items": {} + }, + "tags": { + "items": { + "$ref": "#/components/schemas/Tag" + } + }, + "status": { + "description": "pet status in the store", + "enum": [ + "available", + "pending", + "sold" + ] + } + }, + "required": [ + "name", + "photoUrls" + ] + }, + "Tag": { + "properties": { + "id": { + "format": "int64" + }, + "name": {} + } + }, + "Order": { + "properties": { + "complete": {}, + "id": { + "format": "int64" + }, + "petId": { + "format": "int64" + }, + "quantity": { + "format": "int32" + }, + "shipDate": { + "format": "date-time" + }, + "status": { + "description": "Order Status" + } + } + }, + "ModelApiResponse": { + "properties": { + "code": { + "format": "int32" + }, + "type": {}, + "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-webmvc-core/src/test/resources/results/3.1.0/app4.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.1.0/app4.json new file mode 100644 index 000000000..5c70d7107 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/resources/results/3.1.0/app4.json @@ -0,0 +1,70 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/values/data": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "list", + "parameters": [ + { + "name": "toto", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v31.app4.TrackerData" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v31.app4.TrackerData" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "test.org.springdoc.api.v31.app4.TrackerData": { + "properties": { + "trackerId": { + "example": "the-tracker-id" + }, + "timestamp": { + "format": "date-time", + "example": "2018-01-01T00:00:00Z" + }, + "value": { + "format": "double", + "description": "The data value", + "example": 19.0 + } + }, + "required": [ + "timestamp", + "trackerId", + "value" + ] + } + } + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app4.json b/springdoc-openapi-webmvc-core/src/test/resources/results/app4.json deleted file mode 100644 index 1f8469847..000000000 --- a/springdoc-openapi-webmvc-core/src/test/resources/results/app4.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "OpenAPI definition", - "version": "v0" - }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "paths": { - "/values/data": { - "post": { - "tags": [ - "hello-controller" - ], - "operationId": "list", - "parameters": [ - { - "name": "toto", - "in": "query", - "required": true, - "schema": { - "$ref": "#/components/schemas/test.org.springdoc.api.app4.TrackerData" - } - } - ], - "responses": { - "200": { - "description": "OK", - "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", - "example": "the-tracker-id" - }, - "timestamp": { - "type": "string", - "format": "date-time", - "example": "2018-01-01T00:00:00Z" - }, - "value": { - "type": "number", - "description": "The data value", - "format": "double", - "example": 19.0 - } - } - } - } - } -}