Skip to content

incorrect generic param for multi interfaces #1696

Closed
@dino-proj

Description

@dino-proj

bug

interface One

public interface ListControllerBase<S extends Service<?, ?>, Vo,  SRC extends CustomQuery> {

  // define an operation
  @Operation(name="list")
  @PostMapping("list")
  default Response<Vo> list(@RequestBody PostBody<SRC> req) {
    // some code
  }
}

interface Two

public interface ExistsControllerBase<S extends Service<?, ?>, EQUERY extends CustomQuery> {

  // define another operation
  @Operation(name="exist")
  @PostMapping("exist")
  default Response<Boolean> exist(@RequestBody PostBody<EQUERY> req) {
    // some code
  }

}

inherit operations from those interfaces defined above

@RestController
@RequestMapping("/v1/{tenant_id:[0-9A-Z]+}/user")
public class UserAdminController implements 
    ListControllerBase<AdminUserService, AdminUserVo, AdminUserSearch>,
    ExistsControllerBase<AdminUserService, UserExistsQuery> {
    // some code
}

the "requestBody" in "/v1/{tenant_id}/user/exist" path get incorrect schema:

"schema": {
   "$ref": "#/components/schemas/PostBodyCustomQuery"
}

the correct schema should be:

"schema": {
   "$ref": "#/components/schemas/PostBodyUserExistsQuery"
}

PostBodyCustomQuery ---> PostBodyUserExistsQuery

fix hint

in file: springdoc-openapi-common/src/main/java/org/springdoc/core/ReturnTypeParser.java

//this method
static ResolvableType resolveVariable(TypeVariable<?> typeVariable, ResolvableType contextType) {

//...
}

pull request: at #1684

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions