springdoc / springdoc-openapi

Library for OpenAPI 3 with spring-boot
https://springdoc.org
Apache License 2.0
3.26k stars 493 forks source link

Ref not found with multiple ControllerAdvice handlers #2619

Closed fls-pushvv closed 3 months ago

fls-pushvv commented 3 months ago

There is a controller advice like this

 @ResponseStatus(HttpStatus.**BAD_REQUEST**)
    @ExceptionHandler({
            MissingServletRequestParameterException.class,
            HttpMessageNotReadableException.class})
    public **String** badRequestException(Exception ex) {
        return logExceptionAndGetUserMessage(ex);
    }

    @ResponseStatus(HttpStatus.**BAD_REQUEST**)
    @ExceptionHandler(MethodArgumentNotValidException.class)
    public **ValidationError** handleValidationExceptions(MethodArgumentNotValidException ex) {
      .....
        return validationError;
    }

When I try to open a controller method in swagger-ui I see this:

Resolver error at paths./appeal-to-project/find-appeals.get.responses.400.content.*/*.schema.oneOf.1.$ref
Could not resolve reference: Could not resolve pointer: /components/schemas/ValidationError does not exist in document

When I look into components.schemas there is no ValidationError.

However, if I remove the first method (the one returning the String), then the ValidationError schema is generated.

I think the schema should always be generated.

bnasslahsen commented 3 months ago

Not reproducible. Feel free to provide a Minimal, Reproducible Example - with HelloController that reproduces the problem.

This ticket will be closed, but can be reopened if your provide the reproducible sample.