jhipster with webflux - Swagger is not working

1k views Asked by At

I am getting this error with jhipster+webflux, Gateway application error(JWT) Application --> registry--gateway(angular)--multiple services(webflux) http://localhost:8080/admin/docs

"type" : "https://www.jhipster.tech/problem/problem-with-message", "title" : "Not Found", "status" : 404, "detail" : "404 NOT_FOUND", "path" : "/swagger-ui.html", "message" : "error.http.404"

.yo-rc.json

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "org.abc.gateway",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "6.10.3",
    "applicationType": "gateway",
    "baseName": "gateway",
    "packageName": "org.abc.gateway",
    "packageFolder": "org/abc/gateway",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "no",
    "enableHibernateCache": false,
    "websocket": false,
    "databaseType": "mongodb",
    "devDatabaseType": "mongodb",
    "prodDatabaseType": "mongodb",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSwaggerCodegen": true,
    "jwtSecretKey": "XXXXXXXXXXXXXXXX",
    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1602227915588,
    "testFrameworks": ["gatling", "cucumber", "protractor"],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": ["en", "hi"],
    "blueprints": [],
    "reactive": true
  }
}

Error in swagger initialization

java.lang.NoSuchMethodError: springfox.documentation.spi.service.contexts.ParameterContext.(Lspringfox/documentation/service/ResolvedMethodParameter;Lspringfox/documentation/builders/ParameterBuilder;Lspringfox/documentation/spi/service/contexts/DocumentationContext;Lspringfox/documentation/spi/schema/GenericTypeNamingStrategy;Lspringfox/documentation/spi/service/contexts/OperationContext;)V

What do i need to check, to get swagger enabled with spring-Webflux projects..

1

There are 1 answers

0
Johann R. On

I found an issue in jhipster project : https://github.com/jhipster/generator-jhipster/issues/12072#issuecomment-683282300

To fix it :

1- update the dependencies (remove the old dependencies)

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-boot-starter</artifactId>
        <version>${springfox.version}</version>
        <exclusions>
            <exclusion>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-bean-validators</artifactId>
            </exclusion>
            <exclusion>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-bean-validators</artifactId>
        <version>${springfox.version}</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>${springfox.version}</version>
    </dependency>

2 - update the path "/v2/api-docs" to "/v3/api-docs" in the whole project (front + back)

3 - in docs.component.html change the URI

<iframe src="./swagger-ui/" width="100%" height="900" seamless
    target="_top" title="Swagger UI" class="border-0"></iframe>

4 - I had a problem with the security. I allow the swagger resource to permit all in SecurityConfiguration Since I disable Swagger in production spring profile, it is not a problem for me.