Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find a model that matches key in 3.0-SNAPSHOT and Spring WebFlux #3348

Closed
mdsina opened this issue Jun 26, 2020 · 0 comments · Fixed by #3350
Closed

Unable to find a model that matches key in 3.0-SNAPSHOT and Spring WebFlux #3348

mdsina opened this issue Jun 26, 2020 · 0 comments · Fixed by #3350
Labels
Milestone

Comments

@mdsina
Copy link

mdsina commented Jun 26, 2020

I have an issues with generation of some swagger json.

I have method like that:

@GetMapping(value = "{callId}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
    @Timed
    public Mono<ResponseEntity<InputStreamResource>> getJavaScriptCall(@PathVariable("callId") String callId) {

that returns file to me for downloading.

But when I call v2/api-docs

I receive this:

                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "Error-ModelName{namespace='org.springframework.http', name='ResponseEntityOfInputStreamResource'}",
                            "originalRef": "Error-ModelName{namespace='org.springframework.http', name='ResponseEntityOfInputStreamResource'}"
                        }
                    },

How can I tune Springfox to generate correct swagger specification?
I was trying that. But that didn't work for type ResponseEntity<InputStreamResource>

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

Configuration for webflux support enabled:

@Configuration
@EnableSwagger2WebFlux
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig {

I use springfox-swagger2:3.0.0-SNAPSHOT version
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants