Generator-jhipster: Swagger not listing actuator endpoints

Created on 9 Oct 2018  ·  6Comments  ·  Source: jhipster/generator-jhipster

Overview of the issue

When swagger is enabled, both default(app) and the Spring boot actuator springfox dockets are added to the swagger configuration, but only the default endpoints are shown in the UI.

This can also be verified in http://host:port/contextroot/swagger-resources, it is missing the /management group.

Motivation for or Use Case

Swagger should ideally expose both application and actuator endpoints for an app.

Reproduce the error

Generate a monilithic react/angular app using generator-jhipster.
./mvnw
npm start
Login as admin
Click on Administration->API
Notice that only default(/v2/api-docs) is listed in the drop down. I would expect management (/v2/api-docs?groups=management) as another item in the drop down.

Generate a microservice app
Open http://host:port/appname/swagger-resouces
Verify that is not listing the /v2/api-docs?group=management group
[ {
"name" : "default",
"url" : "/v2/api-docs",
"swaggerVersion" : "2.0",
"location" : "/v2/api-docs"
} ]

Related issues

Found a few related to actuator endpoints, but nothing recent.

Suggest a Fix

Remove line https://github.com/jhipster/jhipster/blob/43585a5dd8b01993fc23b3ad3ca355f3bdb7b63c/jhipster-framework/src/main/java/io/github/jhipster/config/apidoc/SwaggerAutoConfiguration.java#L132

Not sure all the nuances of @ConditionalOnClass, its definitely not finding org.springframework.boot.actuate.autoconfigure.ManagementServerProperties in the classpath. Do we really need to check the availability of this class for the actuator endpoints to be made available?

JHipster Version(s)

5.4.1

JHipster configuration

Using JHipster version installed locally in current project's node_modules
Executing jhipster:info
Options: from-cli: true
Welcome to the Hipster Information Sub-Generator

JHipster Version(s)
[email protected] /Users/xxx/yyy/reacttest
└── [email protected] 

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany.myapp"
    },
    "jhipsterVersion": "5.4.1",
    "applicationType": "monolith",
    "baseName": "reacttest",
    "packageName": "com.mycompany.myapp",
    "packageFolder": "com/mycompany/myapp",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": “xxx”,
    "clientFramework": "react",
    "useSass": true,
    "clientPackageManager": "npm",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": false
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory


JDL entity definitions


Environment and Tools

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

git version 2.12.2

node: v10.10.0

npm: 6.4.1

yeoman: 2.0.1

yarn: 1.3.2

Docker version 18.06.0-ce, build 0ffa825

docker-compose version 1.22.0, build f46880f

Congratulations, JHipster execution is complete!

Entity configuration(s) entityName.json files generated in the .jhipster directory

None

Browsers and Operating System

MacOS Mojave, Chrome 69.0.3497.100

  • [x] Checking this box is mandatory (this is just to show you read everything)

Most helpful comment

In your application.yml, try to change the properties:

jhipster:
    swagger:
        default-include-pattern: /(api|management)/.*

It should appear in swagger, but in the same group (instead of a specific one)

All 6 comments

It was working properly but it doesn't work anymore 😢! Maybe because the property was changed in Spring Boot 2. I will have a look.

I noticed this

On Tue, 9 Oct 2018, 5:52 pm Pierre Besson, notifications@github.com wrote:

It was working properly but it doesn't work anymore 😢! Maybe because the
property was changed in Spring Boot 2. I will have a look.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/jhipster/generator-jhipster/issues/8516#issuecomment-428247229,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABDlF91eGxdRywH9NbgMabNfKfA1iyTvks5ujMZRgaJpZM4XTktN
.

In your application.yml, try to change the properties:

jhipster:
    swagger:
        default-include-pattern: /(api|management)/.*

It should appear in swagger, but in the same group (instead of a specific one)

The @ConditionalOnClass is needed because if the user disable the actuator in his/her app (then the class will be missing), this feature will not work properly and also be useless.

@sazeez I'm on it, I have already found a way to fix this.

Closing this, as the PR https://github.com/jhipster/jhipster/pull/103 has been merged

Was this page helpful?
0 / 5 - 0 ratings