Skip to content

NPEs when using @ParameterGroup with custom Pageable and adding descriptions to fields #1333

Closed
@arjunchhabra-invitae

Description

@arjunchhabra-invitae

Describe the bug

  • When using a custom class that extends from Pageable and receiving it with @ParameterGroup at an endpoint, if you attempt to annotate a field with a description within that class, you will receive an NPE when accessing the generated docs and return a 500.
  • If you use this same class as a @ParameterGroup but remove the reference to Pageable, the docs are generated correctly and the descriptions are displaye.

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using? 2.5.5
  • What modules and versions of springdoc-openapi are you using? 1.5.12
  • What is the actual and the expected result using OpenAPI Description (yml or json)? Expect actual yml/json generation, but receive a 500
  • Provide with a sample code (HelloController) or Test that reproduces the problem

in Controller.kt...

    @GetMapping
    fun getSomething(@ParameterObject example: ExampleClass) {

in ExampleClass.kt...

data class ExampleClass (
    @field:Parameter(description = "Anything")
    val something: Int = 0
) : Pageable {

    override fun getPageNumber(): Int {
        TODO("Not yet implemented")
    }

    override fun getPageSize(): Int {
        TODO("Not yet implemented")
    }

    override fun getOffset(): Long {
        TODO("Not yet implemented")
    }

    override fun getSort(): Sort {
        TODO("Not yet implemented")
    }

    override fun next(): Pageable {
        TODO("Not yet implemented")
    }

    override fun previousOrFirst(): Pageable {
        TODO("Not yet implemented")
    }

    override fun first(): Pageable {
        TODO("Not yet implemented")
    }

    override fun withPage(pageNumber: Int): Pageable {
        TODO("Not yet implemented")
    }

    override fun hasPrevious(): Boolean {
        TODO("Not yet implemented")
    }
}

in ExampleClass2.kt...

data class ExampleClass2 (
    @field:Parameter(description = "Anything")
    val something: Int = 0
)

The above will fail with 500. If you replace ExampleClass with ExampleClass2 in Controller.kt, the docs will generate and include the description.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions