diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocJacksonKotlinModuleConfiguration.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocJacksonKotlinModuleConfiguration.java index 274ffcd67..21fe11497 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocJacksonKotlinModuleConfiguration.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocJacksonKotlinModuleConfiguration.java @@ -1,15 +1,16 @@ package org.springdoc.core.configuration; import com.fasterxml.jackson.module.kotlin.KotlinModule; -import com.fasterxml.jackson.module.kotlin.KotlinModule.Builder; +import org.springdoc.core.properties.SpringDocConfigProperties; import org.springdoc.core.providers.ObjectMapperProvider; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; 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; +import org.springframework.context.annotation.Primary; /** * The type Spring doc kotlin module configuration. @@ -21,16 +22,19 @@ @ConditionalOnClass(KotlinModule.class) @ConditionalOnExpression("${springdoc.api-docs.enabled:true} and ${springdoc.enable-kotlin:true}") @ConditionalOnWebApplication -@ConditionalOnBean(SpringDocConfiguration.class) class SpringDocJacksonKotlinModuleConfiguration { /** - * Instantiates a new Spring doc kotlin module configuration. + * Instantiates a new objectMapperProvider with a kotlin module. * - * @param objectMapperProvider the object mapper provider + * @param springDocConfigProperties the spring doc config properties */ - public SpringDocJacksonKotlinModuleConfiguration(ObjectMapperProvider objectMapperProvider) { - objectMapperProvider.jsonMapper() - .registerModule(new Builder().build()); + + @Bean + @Primary + ObjectMapperProvider objectMapperProvider(SpringDocConfigProperties springDocConfigProperties) { + ObjectMapperProvider mapperProvider = new ObjectMapperProvider(springDocConfigProperties); + mapperProvider.jsonMapper().registerModule(new KotlinModule.Builder().build()); + return mapperProvider; } } diff --git a/springdoc-openapi-tests/pom.xml b/springdoc-openapi-tests/pom.xml index 4d2b3cd81..45a7c9640 100644 --- a/springdoc-openapi-tests/pom.xml +++ b/springdoc-openapi-tests/pom.xml @@ -18,6 +18,7 @@ springdoc-openapi-actuator-webflux-tests springdoc-openapi-actuator-webmvc-tests springdoc-openapi-kotlin-tests + springdoc-openapi-kotlin-mvc-tests springdoc-openapi-hateoas-tests springdoc-openapi-data-rest-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/.gitignore b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/.gitignore new file mode 100644 index 000000000..ab21548c1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/.gitignore @@ -0,0 +1,144 @@ +###################### +# Project Specific +###################### +/target/www/** +/src/test/javascript/coverage/ + +###################### +# Node +###################### +/node/ +node_tmp/ +node_modules/ +npm-debug.log.* +/.awcache/* +/.cache-loader/* + +###################### +# SASS +###################### +.sass-cache/ + +###################### +# Eclipse +###################### +*.pydevproject +.project +.metadata +tmp/ +tmp/**/* +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath +.factorypath +/src/main/resources/rebel.xml + +# External tool builders +.externalToolBuilders/** + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + +###################### +# Intellij +###################### +.idea/ +*.iml +*.iws +*.ipr +*.ids +*.orig +classes/ +out/ + +###################### +# Visual Studio Code +###################### +.vscode/ + +###################### +# Maven +###################### +/log/ +/target/ + +###################### +# Gradle +###################### +.gradle/ +/build/ + +###################### +# Package Files +###################### +*.jar +*.war +*.ear +*.db + +###################### +# Windows +###################### +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini + +###################### +# Mac OSX +###################### +.DS_Store +.svn + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +###################### +# Directories +###################### +/bin/ +/deploy/ + +###################### +# Logs +###################### +*.log* + +###################### +# Others +###################### +*.class +*.*~ +*~ +.merge_file* + +###################### +# Gradle Wrapper +###################### +!gradle/wrapper/gradle-wrapper.jar + +###################### +# Maven Wrapper +###################### +!.mvn/wrapper/maven-wrapper.jar + +###################### +# ESLint +###################### +.eslintcache \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/pom.xml new file mode 100644 index 000000000..a18785cab --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/pom.xml @@ -0,0 +1,83 @@ + + + springdoc-openapi-tests + org.springdoc + 2.2.1-SNAPSHOT + + 4.0.0 + springdoc-openapi-kotlin-mvc-tests + + + + com.fasterxml.jackson.module + jackson-module-kotlin + test + + + org.springdoc + springdoc-openapi-starter-webmvc-api + test + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + test + + + org.springframework.boot + spring-boot-starter-web + test + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + kotlin-maven-plugin + org.jetbrains.kotlin + + + compile + process-sources + + compile + + + + ${project.basedir}/src/main/kotlin + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + + + + + + + spring + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + + \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/AbstractKotlinSpringDocMVCTest.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/AbstractKotlinSpringDocMVCTest.kt new file mode 100644 index 000000000..2a0e48a19 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/AbstractKotlinSpringDocMVCTest.kt @@ -0,0 +1,81 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api + +import org.junit.jupiter.api.Test +import org.skyscreamer.jsonassert.JSONAssert +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.ActiveProfiles +import org.springframework.test.web.servlet.MockMvc +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders +import org.springframework.test.web.servlet.result.MockMvcResultMatchers +import java.nio.charset.StandardCharsets +import java.nio.file.Files +import java.nio.file.Paths + +@SpringBootTest +@AutoConfigureMockMvc +@ActiveProfiles("test") +abstract class AbstractKotlinSpringDocMVCTest { + + @Autowired + val mockMvc: MockMvc? = null + + private val logger = LoggerFactory.getLogger(AbstractKotlinSpringDocMVCTest::class.java) + + @Test + fun testApp() { + var result: String? = null + try { + val response = mockMvc!!.perform(MockMvcRequestBuilders.get("/v3/api-docs")) + .andExpect(MockMvcResultMatchers.status().isOk).andReturn() + + result = response.response.contentAsString + val className = javaClass.simpleName + val testNumber = className.replace("[^0-9]".toRegex(), "") + + val expected = getContent("results/app$testNumber.json") + JSONAssert.assertEquals(expected, result, true) + } catch (e: AssertionError) { + logger.error(result) + throw e + } + } + + companion object { + @Throws(Exception::class) + fun getContent(fileName: String): String { + try { + val path = Paths.get( + AbstractKotlinSpringDocMVCTest::class.java.classLoader.getResource( + fileName + )!!.toURI() + ) + val fileBytes = Files.readAllBytes(path) + return String(fileBytes, StandardCharsets.UTF_8) + } catch (e: Exception) { + throw RuntimeException("Failed to read file: $fileName", e) + } + + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app10/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app10/ExampleController.kt new file mode 100644 index 000000000..077d6bc2f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app10/ExampleController.kt @@ -0,0 +1,20 @@ +package test.org.springdoc.api.app10 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController +import test.org.springdoc.api.app8.Greeting + +data class Greeting(val greeting: String) + +@RestController +class ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?) = Greeting("Hello ${name ?: "world"}") + + @GetMapping("/test") + fun test(@RequestParam name: String) = Greeting("Hello $name") + + @GetMapping("/test-with-default") + fun testWithDefault(@RequestParam(defaultValue = "world") name: String) = Greeting("Hello $name") +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app10/SpringDocApp10Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app10/SpringDocApp10Test.kt new file mode 100644 index 000000000..300a3c02d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app10/SpringDocApp10Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2023 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app10 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest + +class SpringDocApp10Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app10"]) + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app2/SpringDocApp2Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app2/SpringDocApp2Test.kt new file mode 100644 index 000000000..253caa4be --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app2/SpringDocApp2Test.kt @@ -0,0 +1,29 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app2 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest + +class SpringDocApp2Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app2/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app2/SystemStatusController.kt new file mode 100644 index 000000000..5205485dd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app2/SystemStatusController.kt @@ -0,0 +1,43 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app2 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +enum class SystemStatus(val status: String) { + OK("OK") +} + +data class SystemStatusResponse( + val status: SystemStatus +) + +@RestController +@RequestMapping("/status") +class SystemStatusController { + @GetMapping + fun index() = SystemStatusResponse(SystemStatus.OK) + + @GetMapping("/foo") + fun foo() = + SystemStatusResponse(SystemStatus.OK) + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app3/SpringDocApp3Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app3/SpringDocApp3Test.kt new file mode 100644 index 000000000..856022f3a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app3/SpringDocApp3Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app3 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest + +class SpringDocApp3Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app3"]) + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app3/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app3/SystemStatusController.kt new file mode 100644 index 000000000..c07452e9c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app3/SystemStatusController.kt @@ -0,0 +1,43 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app3 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +enum class SystemStatus(val status: String) { + OK("OK") +} + +data class SystemStatusResponse( + val status: SystemStatus +) + +@RestController +@RequestMapping("/status") +class SystemStatusController { + @GetMapping + fun index() = SystemStatusResponse(SystemStatus.OK) + + @GetMapping("/foo") + @Deprecated("") + fun foo() = SystemStatusResponse(SystemStatus.OK) + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app4/HelloController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app4/HelloController.kt new file mode 100644 index 000000000..6d0d9199e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app4/HelloController.kt @@ -0,0 +1,37 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app4 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + + +data class Person( + val name: String, + val nickname: String? +) + +@RestController +@RequestMapping("/test") +class HelloController { + @GetMapping + suspend fun index(s: Person) = s + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app4/SpringDocApp4Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app4/SpringDocApp4Test.kt new file mode 100644 index 000000000..d66e0fd9f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app4/SpringDocApp4Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app4 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest + +class SpringDocApp4Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app4"]) + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app5/ListController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app5/ListController.kt new file mode 100644 index 000000000..262f508b8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app5/ListController.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app5 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/test") +class ListController { + + @GetMapping("/") + fun foo(): List = listOf(1, 2, 3) +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app5/SpringDocApp5Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app5/SpringDocApp5Test.kt new file mode 100644 index 000000000..6d87b74dd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app5/SpringDocApp5Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app5 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest + +class SpringDocApp5Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app5"]) + class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app6/ByteArrayController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app6/ByteArrayController.kt new file mode 100644 index 000000000..f3de98487 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app6/ByteArrayController.kt @@ -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.app6 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +data class Foo(val data: ByteArray) + +@RestController +@RequestMapping("/bytearray") +class ByteArrayController { + + @GetMapping("/") + fun getByteArray(): Foo = Foo(byteArrayOf(0)) + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt new file mode 100644 index 000000000..ef9ca29a5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app6 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest + +class SpringDocApp6Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app6"]) + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app7/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app7/ExampleController.kt new file mode 100644 index 000000000..4f8ca13de --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app7/ExampleController.kt @@ -0,0 +1,17 @@ +package test.org.springdoc.api.app7 + +import io.swagger.v3.oas.annotations.Parameter +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController + +data class Greeting(val greeting: String) + +@RestController +interface ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?): Greeting + + @GetMapping("/test") + fun test(@RequestParam @Parameter(required = true) name: String?): Greeting +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app7/SpringDocApp7Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app7/SpringDocApp7Test.kt new file mode 100644 index 000000000..5b321c55f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app7/SpringDocApp7Test.kt @@ -0,0 +1,46 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app7 + +import org.springframework.aop.framework.ProxyFactory +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.ComponentScan +import org.springframework.context.support.GenericApplicationContext +import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest + +class SpringDocApp7Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app7"]) + class DemoApplication{ + @Bean + fun controller(applicationContext: GenericApplicationContext): ExampleController { + return createProxy(ExampleController::class.java) + } + + private fun createProxy(clazz: Class): T { + val proxyFactory = ProxyFactory(clazz) + proxyFactory.targetClass = clazz + @Suppress("UNCHECKED_CAST") + return proxyFactory.proxy as T + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app8/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app8/ExampleController.kt new file mode 100644 index 000000000..061b2b9eb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app8/ExampleController.kt @@ -0,0 +1,17 @@ +package test.org.springdoc.api.app8 + +import io.swagger.v3.oas.annotations.Parameter +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController + +data class Greeting(val greeting: String) + +@RestController +interface ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?): Greeting + + @GetMapping("/test") + fun test(@RequestParam @Parameter(required = true) name: String?): Greeting +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app8/SpringDocApp8Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app8/SpringDocApp8Test.kt new file mode 100644 index 000000000..3d00589d4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app8/SpringDocApp8Test.kt @@ -0,0 +1,49 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +package test.org.springdoc.api.app8 + +import org.springdoc.core.utils.Constants +import org.springframework.aop.framework.ProxyFactory +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.ComponentScan +import org.springframework.context.support.GenericApplicationContext +import org.springframework.test.context.TestPropertySource +import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest + +@TestPropertySource(properties = [Constants.SPRINGDOC_NULLABLE_REQUEST_PARAMETER_ENABLED+"=false"]) +class SpringDocApp8Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app8"]) + class DemoApplication{ + @Bean + fun controller(applicationContext: GenericApplicationContext): ExampleController { + return createProxy(ExampleController::class.java) + } + + private fun createProxy(clazz: Class): T { + val proxyFactory = ProxyFactory(clazz) + proxyFactory.targetClass = clazz + @Suppress("UNCHECKED_CAST") + return proxyFactory.proxy as T + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app9/DemoController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app9/DemoController.kt new file mode 100644 index 000000000..6b8793276 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app9/DemoController.kt @@ -0,0 +1,71 @@ +package test.org.springdoc.api.app9 + +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/api/demo") +class DocumentsApiController { + + @GetMapping + suspend fun getDocuments( request: DemoRequest + ): DemoDto = DemoDto(42) +} + +data class DemoDto( + var id: Long, +) + +class DemoRequest ( + + @field:Schema(required = true, defaultValue = "a default value") + val requiredNullableDefault: String?, + + @field:Schema(required = true) + val requiredNullableNoDefault: String?, + + @field:Schema(required = true, defaultValue = "a default value") + val requiredNoNullableDefault: String, + + @field:Schema(required = true) + val requiredNoNullableNoDefault: String, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") + val requiredNullableDefault1: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) + val requiredNullableNoDefault1: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") + val requiredNoNullableDefault1: String, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) + val requiredNoNullableNoDefault1: String, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") + val noRequiredNullableDefault2: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) + val noRequiredNullableNoDefault2: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") + val noRequiredNoNullableDefault2: String, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) + val noRequiredNoNullableNoDefault2: String, + + @field:Schema(defaultValue = "a default value") + val noRequiredNullableDefault: String?, + + @field:Schema + val noRequiredNullableNoDefault: String?, + + @field:Schema(defaultValue = "a default value") + val noRequiredNoNullableDefault: String, + + @field:Schema + val noRequiredNoNullableNoDefault: String, + +) diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app9/SpringDocApp9Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app9/SpringDocApp9Test.kt new file mode 100644 index 000000000..424b16a56 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app9/SpringDocApp9Test.kt @@ -0,0 +1,9 @@ +package test.org.springdoc.api.app9 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest + +class SpringDocApp9Test: AbstractKotlinSpringDocMVCTest() { + @SpringBootApplication + class DemoApplication +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/application-test.yml b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/application-test.yml new file mode 100644 index 000000000..544f357e4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/application-test.yml @@ -0,0 +1,9 @@ +spring: + main: + banner-mode: "off" + lazy-initialization: true +logging: + level: + root: ERROR + pattern: + console: '%m%n' \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/logback-test.xml b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/logback-test.xml new file mode 100644 index 000000000..a715d5a44 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/logback-test.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app1.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app1.json new file mode 100644 index 000000000..2c599857a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app1.json @@ -0,0 +1,51 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Kotlin API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v1" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/test/{id}": { + "get": { + "tags": [ + "controller-with-continuation-parameter" + ], + "summary": "Ignore Continuation parameter", + "operationId": "get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app10.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app10.json new file mode 100644 index 000000000..748116b2e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app10.json @@ -0,0 +1,121 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "test", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test-with-default": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "testWithDefault", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string", + "default": "world" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Greeting": { + "required": [ + "greeting" + ], + "type": "object", + "properties": { + "greeting": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app2.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app2.json new file mode 100644 index 000000000..b555db2b4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app2.json @@ -0,0 +1,73 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/status": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "index", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + } + } + }, + "/status/foo": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "foo", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SystemStatusResponse": { + "required": [ + "status" + ], + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "OK" + ] + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app3.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app3.json new file mode 100644 index 000000000..2791ec557 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app3.json @@ -0,0 +1,74 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/status": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "index", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + } + } + }, + "/status/foo": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "foo", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + }, + "deprecated": true + } + } + }, + "components": { + "schemas": { + "SystemStatusResponse": { + "required": [ + "status" + ], + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "OK" + ] + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app4.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app4.json new file mode 100644 index 000000000..c0a5acd97 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app4.json @@ -0,0 +1,63 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "index", + "parameters": [ + { + "name": "s", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Person" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Person": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "nickname": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app5.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app5.json new file mode 100644 index 000000000..5e7be5662 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app5.json @@ -0,0 +1,40 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test/": { + "get": { + "tags": [ + "list-controller" + ], + "operationId": "foo", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "integer", + "format": "int32" + } + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app6.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app6.json new file mode 100644 index 000000000..03e359ee6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app6.json @@ -0,0 +1,51 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/bytearray/": { + "get": { + "tags": [ + "byte-array-controller" + ], + "operationId": "getByteArray", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Foo" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Foo": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "type": "string", + "format": "byte" + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app7.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app7.json new file mode 100644 index 000000000..a501dc369 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app7.json @@ -0,0 +1,90 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "test", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Greeting": { + "required": [ + "greeting" + ], + "type": "object", + "properties": { + "greeting": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app8.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app8.json new file mode 100644 index 000000000..a501dc369 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app8.json @@ -0,0 +1,90 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "test", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Greeting": { + "required": [ + "greeting" + ], + "type": "object", + "properties": { + "greeting": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app9.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app9.json new file mode 100644 index 000000000..16afb1792 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/resources/results/app9.json @@ -0,0 +1,133 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/api/demo": { + "get": { + "tags": [ + "documents-api-controller" + ], + "operationId": "getDocuments", + "parameters": [ + { + "name": "request", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/DemoRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/DemoDto" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "DemoRequest": { + "required": [ + "noRequiredNoNullableNoDefault", + "requiredNoNullableDefault", + "requiredNoNullableDefault1", + "requiredNoNullableNoDefault", + "requiredNoNullableNoDefault1", + "requiredNullableDefault", + "requiredNullableDefault1", + "requiredNullableNoDefault", + "requiredNullableNoDefault1" + ], + "type": "object", + "properties": { + "requiredNullableDefault": { + "type": "string", + "default": "a default value" + }, + "requiredNullableNoDefault": { + "type": "string" + }, + "requiredNoNullableDefault": { + "type": "string", + "default": "a default value" + }, + "requiredNoNullableNoDefault": { + "type": "string" + }, + "requiredNullableDefault1": { + "type": "string", + "default": "a default value" + }, + "requiredNullableNoDefault1": { + "type": "string" + }, + "requiredNoNullableDefault1": { + "type": "string", + "default": "a default value" + }, + "requiredNoNullableNoDefault1": { + "type": "string" + }, + "noRequiredNullableDefault2": { + "type": "string", + "default": "a default value" + }, + "noRequiredNullableNoDefault2": { + "type": "string" + }, + "noRequiredNoNullableDefault2": { + "type": "string", + "default": "a default value" + }, + "noRequiredNoNullableNoDefault2": { + "type": "string" + }, + "noRequiredNullableDefault": { + "type": "string", + "default": "a default value" + }, + "noRequiredNullableNoDefault": { + "type": "string" + }, + "noRequiredNoNullableDefault": { + "type": "string", + "default": "a default value" + }, + "noRequiredNoNullableNoDefault": { + "type": "string" + } + } + }, + "DemoDto": { + "required": [ + "id" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + } + } +}