Swagger 3.0.0 + WebFlux: what is wrong or missing from my settings?

Viewed 682

Helo! Sorry for my English, but it's not my native language. I'm trying to make a project to practice webflux and I can't get Swagger to work. I did a good search on StackOverflow and Google and couldn't find a solution. I also tried looking in the SpringFox documentation, but maybe I didn't quite understand. I decided to ask my first question to StackOverflow:

What is missing from my project settings to make Swagger work?

build.gradle root:

    buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.9.RELEASE"
    }
}

plugins {
    id "application"
    id 'java'
    id 'org.springframework.boot' version '2.1.9.RELEASE'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id "io.freefair.lombok" version "5.1.0"
}

dependencies {
    compile project(":contract")
}

mainClassName = 'com.pocwebflux.PocWebfluxApplication'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
    jcenter()
}

allprojects {
    apply plugin: 'java'
    apply plugin: 'io.spring.dependency-management'
    apply plugin: 'io.freefair.lombok'
    apply plugin: 'org.springframework.boot'

    group = 'com.example'
    version = "1.0.0-SNAPSHOT"

    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11

    repositories {
        mavenCentral()
    }

    test {
        useJUnitPlatform()
    }

    dependencyManagement {
        imports {
            mavenBom "org.springframework.boot:spring-boot-dependencies:2.1.9.RELEASE"
        }
    }

    dependencies {
        implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive'
        implementation 'org.springframework.boot:spring-boot-starter-webflux'
        implementation "io.springfox:springfox-boot-starter:3.0.0"
        compile 'io.springfox:springfox-swagger-ui:3.0.0'
        compileOnly 'org.projectlombok:lombok'
        annotationProcessor 'org.projectlombok:lombok'
        testImplementation 'org.springframework.boot:spring-boot-starter-test'
        testImplementation 'io.projectreactor:reactor-test'
        testImplementation 'io.projectreactor:reactor-test'
        testImplementation 'org.mockito:mockito-junit-jupiter'
        testImplementation 'org.junit.jupiter:junit-jupiter-engine'
        testImplementation 'org.junit.jupiter:junit-jupiter-api'
        testImplementation 'org.junit.jupiter:junit-jupiter-engine'
        testImplementation 'org.junit.jupiter:junit-jupiter-params'
    }

    test {
        useJUnitPlatform()
    }
}

build.gradle contract layer:

dependencies {
    implementation project(':impl')
}

impl layer: nothing

I still don't have anything implementing just a controller with a test endpoint, just to see if the swagger was working:

ClientController

I created this class following the documentation, but I'm not sure where to use it:

SwaggerUiWebFluxConfigurer

What would be missing from the settings?

Could someone please clarify my question? Thank you very much.

I forgot to say that the build project normally and the service goes up and returns 200 in Postman.

1 Answers

After a series of tries and researches, I found that my problem was with Intellij. I had a cash problem, and I wasn't downloading the dependencies. I did a ./gradlew clean, deleted all springfox and swagger libraries. I went to the root of the project and deleted the ".idea" folder. I downloaded the dependencies again and it includes this:

implementation group: 'org.springframework.plugin', name: 'spring-plugin-core', version: '2.0.0.RELEASE'

Done!

Now it's working.

enter image description here

Related