Search code examples
springspring-webfluxopenapireactivespringdoc-openapi-ui

Springboot webflux with custom openapi spec file fails


I am trying to point my springboot application at custom api spec file with the below configuration

  1. Added api.yml to resources > static folder.
  2. Updated the springboot properties.
spring-doc:
  swagger-ui:
    path: /swagger-ui.html
    enabled: true
    url: "/api.yml"
    defaultModelsExpandDepth: -1
  api-docs:
    path: /api-docs
    enabled: true

I am using the below dependency

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
            <version>2.2.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.yaml</groupId>
                    <artifactId>snakeyaml</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

I am using the openApi Spec sample from here https://editor.swagger.io/?url=https://crop-pal.org/oas3/oas3.yaml

Eventually I get the error

enter image description here

Checked the documentation without much help. Can you point me what I am doing incorrectly or is it not supported for webflux.


Solution

  • I could find a decent solution for this issue finally. The catch was that my application was a Spring Cloud Gateway Application.

    Having said that the solution was clearly detailed in the blog

    https://medium.com/@pubuduc.14/swagger-openapi-specification-3-integration-with-spring-cloud-gateway-part-2-1d670d4ab69a

    Also added routing configurations via properties after adding respective swagger configs for the target microservices and every thing worked fine.