springdoc / springdoc-openapi-demos

Demo for OpenAPI 3 with spring-boot
http://springdoc.org
Apache License 2.0
493 stars 267 forks source link

openapi3 integration with webflux functional way is not working #46

Closed srivi1225 closed 1 year ago

srivi1225 commented 2 years ago

I am trying to integrate openapi3 with reactive webflux functional endpoints. but i am always getting the error message "invalid version" from andother route configuration.andOther(route(RequestPredicates.all(), errorHandler::invalidVersion)). If i remove that validation swagger is working but the version validation is failing.below is my custom router.

route()
        .add((RouterFunction<ServerResponse>) routerFunctionMappings
            .stream()
            .map(routemapping -> Tuples.of(routemapping.getVersion(),
                routeForVersion(routemapping.getRouteMapping())))
            .reduce(Tuples.of("test", route()), (tupel2RouteFunction1, tupel2RouteFunction2) ->
                Tuples.of("test", tupel2RouteFunction1
                    .getT2()
                    .path(
                        tupel2RouteFunction2.getT1(),
                        () -> (RouterFunction<ServerResponse>) tupel2RouteFunction2
                            .getT2()
                            .build()
                            .andOther(
                                route(RequestPredicates.all(), handler::validate)))))
            .getT2()
            .build()
            .andOther(route(RequestPredicates.all(), errorHandler::invalidVersion)))
        .build()
        .filter(filterFunction());

Please help me how to resolve this to make both validation and swagger works.

srivi1225 commented 2 years ago

I found the solution. this got resolved when i updated this line.andOther(route(RequestPredicates.all(), errorHandler::invalidVersion)) to .andOther(route(RequestPredicates .pathPredicates(PathPatternParser.defaultInstance) .apply("/swagger-doc/**").negate(), errorHandler::versionNotSupported))