question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Error-ModelName{namespace='java.lang', name='Void'}" in 3.0.0 springfox + webflux

See original GitHub issue

I have Docket configured like that:

        Docket docket = new Docket(DocumentationType.SWAGGER_2)
            .alternateTypeRules(
                newRule(
                    typeResolver.resolve(List.class, LocalDateTime.class),
                    typeResolver.resolve(List.class, String.class)
                ),
                newRule(
                    typeResolver.resolve(List.class, LocalDate.class),
                    typeResolver.resolve(List.class, String.class)
                )
            )
            .apiInfo(apiInfo)
            .securitySchemes(Collections.singletonList(oauth()))
            .securityContexts(List.of(securityContext()))
            .forCodeGeneration(true)
            .directModelSubstitute(java.nio.ByteBuffer.class, String.class)
            .genericModelSubstitutes(Mono.class, Flux.class, Publisher.class)
            .host(host)
            .protocols(protocols)
            .select()
            .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
            .paths(regex(swaggerProperties.getDefaultIncludePattern()))
            .build();

And have an API method that return Flux<Void>

    @PostMapping("refresh")
    public Flux<Void> refresh() {
        return callsProvider.refresh().subscribeOn(Schedulers.elastic());
    }

But in JSON I’ve got an error:

                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "type": "array",
                            "items": {
                                "$ref": "Error-ModelName{namespace='java.lang', name='Void'}",
                                "originalRef": "Error-ModelName{namespace='java.lang', name='Void'}"
                            }
                        }
                    },

Adding .ignoredParameterTypes(Void.class) to Docket didn’t help.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
ajuraszcommented, Aug 5, 2020

I came across similar issue yesterday. But in my case from what I can see it is related to consuming multipart/form-data ie.

    @PutMapping(value = "/{name}/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ApiOperation(value = "Sample upload method")
    ResponseEntity<Void> test(
            @ApiParam(value = "Name", required = true) @PathVariable String name,
            @ApiParam(value = "Uploaded file", required = true) @RequestPart("file") MultipartFile file
    ) {
        return ResponseEntity.accepted().build();
    }

then I got the same error as in issue title, but JSON was a little bit different:

        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/Error-ModelName{namespace='java.lang', name='Void'}"
            }
          }
      }

For now, I have workaround were I explicitly override 200 status code with:

    @ApiResponses({
            @ApiResponse(code = 200, message = "OK")
    })

EDIT:

While trying to debug the issue I have found the following property:

springfox.documentation.swagger.use-model-v3

which fixes the above issue when set to false as it does not use open API v3.

1reaction
ManolisPapdcommented, Aug 23, 2022

Maybe it’s not suitable for everyone but a workaround in my case was to remove a redundant produces attribute from HTTP method annotations.

For example:

@PutMapping(path = "/test", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Void>(....)

Changed to:

@PutMapping(path = "/test")
public ResponseEntity<Void>(....)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Suddenly Springfox Swagger 3.0 is not working with spring ...
This is how it worked for me. I am using InteliJ IDEA, SpringBoot and Maven. When adding Swagger dependencies as: <dependency> <groupId>io.
Read more >
Springfox Reference Documentation - GitHub Pages
Springfox works by examining an application, once, at runtime to infer API semantics based on spring configurations, class structure and various ...
Read more >
failed to start bean 'documentationpluginsbootstrapper ...
Spring boot Swagger implementation using Spring Fox Failed to start bean ... implementation('io.springfox:springfox-spring-webflux:3.0.0-SNAPSHOT') ...
Read more >
springfox-spring-integration-webflux : 3.0.0 - Maven Central
springfox -spring-integration-webflux - JSON API documentation for spring based applications. ... io.springfox:springfox-spring-integration-webflux 3.0.0.
Read more >
springfox-swagger2 » 2.10.3 - Maven Repository
io.springfox » springfox-spring-webmvc · 2.10.3 · 3.0.0. Apache 2.0, logo, io.springfox » springfox-spring-webflux · 2.10.3 · 3.0.0.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found