You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
While defining the controller as an abstraction and using generic as a response, the example and schema in the swagger are empty.
To Reproduce
I have generic controller to provide crud methods as follows:
abstract class BaseCrudController<T, E : BaseEntityModel>(private val baseCrudService: BaseCrudService<T, E>) {
...
@GetMapping("/{sid}")
open fun read(@PathVariable sid: String): Mono<ResponseEntity<T>> =
baseCrudService.read(sid)
.map { ResponseEntity.ok().body(it) }
.defaultIfEmpty(ResponseEntity.notFound().build())
...
}
and this is used in User controller implementation:
@RestController
@RequestMapping("api/import/user")
class UsrController(userService: UserService) :
BaseCrudController<User, UserEntity>(userService)
User class contains the definition of swagger schema:
data class User(
@get:Schema(
title = "Speaking Id of User",
pattern = Pattern.speakingId,
example = "newUser"
)
val sid: String
)
Expected behavior
I should see the example and schema. In version 1.4.4 it still not works.
Additional context
I found if I define result differently then it works: Mono<ResponseEntity<T>> -> Mono<T>
but in this case, I am losing the possibility to control response, I mean I have to control it differently (by exception handler).
Also if this controller is not defined as abstract the definition of endpoints are under a class with @RestController the Mono<ResponseEntity<User>> works like a charm.
The text was updated successfully, but these errors were encountered:
baxol
changed the title
Empty response example and schema using abstract generic
Example and schema is empty while using abstract generic
Aug 18, 2020
baxol
changed the title
Example and schema is empty while using abstract generic
Example and schema of response is empty while using abstract generic
Aug 18, 2020
Not sure that there is any standard spring API that can achieve your goal: GenericTypeResolver.resolveType, doesn't seem to handle your case of nested generics.
I have added a fix to to handle this case. You can please validate this fix with the latest SNAPSHOT?
Here is the link to configure the snapshots:
Describe the bug
While defining the controller as an abstraction and using generic as a response, the example and schema in the swagger are empty.
To Reproduce
I have generic controller to provide crud methods as follows:
and this is used in User controller implementation:
User class contains the definition of swagger schema:
Expected behavior
I should see the example and schema. In version 1.4.4 it still not works.
Additional context
I found if I define result differently then it works:
Mono<ResponseEntity<T>>
->Mono<T>
but in this case, I am losing the possibility to control response, I mean I have to control it differently (by exception handler).
Also if this controller is not defined as abstract the definition of endpoints are under a class with @RestController the
Mono<ResponseEntity<User>>
works like a charm.The text was updated successfully, but these errors were encountered: