Skip to content

Commit 4fedf23

Browse files
committed
fix openapi properties mapping
1 parent b5b682a commit 4fedf23

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

openapi/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependencies {
22
implementation(project(":server"))
3-
api("io.swagger.core.v3:swagger-annotations:2.2.29")
3+
api("io.swagger.core.v3:swagger-annotations:2.2.30")
44

55
testImplementation(project(":json"))
66
testImplementation(project(":jackson"))

openapi/src/Generate.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private fun KType.toJsonSchema(response: Boolean = false): Map<String, Any?>? {
103103
else -> null
104104
})
105105
else -> mapOfNotNull("type" to "object",
106-
"properties" to cls.publicProperties.map { it.key to it.value.returnType.toJsonSchema(response) }.takeIf { it.isNotEmpty() },
106+
"properties" to cls.publicProperties.mapValues { it.value.returnType.toJsonSchema(response) }.takeIf { it.isNotEmpty() },
107107
"required" to cls.publicProperties.values.filter { p ->
108108
!p.returnType.isMarkedNullable && (response || cls.primaryConstructor?.parameters?.find { it.name == p.name }?.isOptional != true)
109109
}.map { it.name }.toSet().takeIf { it.isNotEmpty() })

openapi/test/OpenAPITest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class OpenAPITest {
121121
"operationId" to "MyRoutes.saveUser",
122122
"tags" to listOf("MyRoutes"),
123123
"parameters" to emptyList<Any>(),
124-
"requestBody" to mapOf("description" to "Application and applicant", "required" to true, "content" to userSchema(), "required" to true),
124+
"requestBody" to mapOf("description" to "Application and applicant", "required" to true, "content" to userSchema()),
125125
"responses" to mapOf(
126126
OK to mapOf("description" to "OK", "content" to userSchema(response = true)),
127127
BadRequest to mapOf("description" to "Very bad request"),

0 commit comments

Comments
 (0)