Skip to content

Commit

Permalink
Object schema generated for Unit Kotlin type. Fixes springdoc#2798
Browse files Browse the repository at this point in the history
  • Loading branch information
bnasslahsen committed Dec 29, 2024
1 parent 3f755ac commit 896471f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import io.swagger.v3.oas.annotations.Parameter
import org.springdoc.core.customizers.KotlinDeprecatedPropertyCustomizer
import org.springdoc.core.customizers.ParameterCustomizer
import org.springdoc.core.providers.ObjectMapperProvider
import org.springdoc.core.service.AbstractRequestService.addRequestWrapperToIgnore
import org.springdoc.core.utils.Constants
import org.springdoc.core.utils.SpringDocUtils
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean
Expand Down Expand Up @@ -69,6 +70,7 @@ class SpringDocKotlinConfiguration() {
*/
init {
SpringDocUtils.getConfig()
.addResponseTypeToIgnore(Unit::class.java)
.addRequestWrapperToIgnore(Continuation::class.java)
.addDeprecatedType(Deprecated::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@

package test.org.springdoc.api.app2

import jakarta.validation.Valid
import kotlinx.coroutines.reactor.mono
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController

enum class SystemStatus(val status: String) {
Expand All @@ -41,4 +47,13 @@ class SystemStatusController {
fun foo() = mono {
SystemStatusResponse(SystemStatus.OK)
}

@PostMapping("{token}/activate")
@ResponseStatus(HttpStatus.NO_CONTENT)
suspend fun activateUser(
@PathVariable token: String,
@RequestBody @Valid request: String
) {
// do something
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,40 @@
}
],
"paths": {
"/status/{token}/activate": {
"post": {
"tags": [
"system-status-controller"
],
"operationId": "activateUser",
"parameters": [
{
"name": "token",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "string"
}
}
},
"required": true
},
"responses": {
"204": {
"description": "No Content",
"content": {}
}
}
}
},
"/status": {
"get": {
"tags": [
Expand Down

0 comments on commit 896471f

Please sign in to comment.