Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected path behaviour when using management port (actuator) #1603

Closed
Okeanos opened this issue Apr 8, 2022 · 4 comments
Closed

Unexpected path behaviour when using management port (actuator) #1603

Okeanos opened this issue Apr 8, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@Okeanos
Copy link

Okeanos commented Apr 8, 2022

Is your feature request related to a problem? Please describe.
When using the actuator support the OpenAPI definition and SwaggerUI pieces are hinted at to be available via the actuators openapi and swaggerui, resulting in the following paths:

  • http://localhost:8081/actuator/openapi/
  • http://localhost:8081/actuator/swaggerui/

A special case is described when springdoc.use-management-port is undefined or set to false. However, in case it is set to true I would expect that these two APIs are the only ones I actually need. The reality is that calling http://localhost:8081/actuator/swaggerui/ will redirect to http://localhost:8081/actuator/swagger-ui/index.html– which is an altogether different path. There doesn't appear to be a way to serve everything from the swaggerui actuator endpoint, not even when using the rewrite directives (springdoc.swagger-ui.path and springdoc.webjars.prefix).

The following two spring profiles behave exactly the same:

management:
  endpoints:
    enabled-by-default: true
    web:
      exposure:
        include: ["openapi", "swaggerui"]
  server:
    port: 8081

---
spring:
  config:
    activate:
      on-profile: default-behavior
springdoc:
  show-actuator: true
  api-docs:
    enabled: true
  swagger-ui:
    enabled: true
    disable-swagger-default-url: true
    validatorUrl: null
  use-management-port: true

---
spring:
  config:
    activate:
      on-profile: rewrite-behavior
springdoc:
  show-actuator: true
  api-docs:
    enabled: true
    path: /swaggerui/swagger.json
  swagger-ui:
    enabled: true
    path: /swaggerui
    disable-swagger-default-url: true
    validatorUrl: null
  webjars:
    prefix: /swaggerui/webjars
  use-management-port: true

Describe the solution you'd like
I would like better documentation for the interaction between path properties and use-management-port / show-actuator / management.endpoints.web.exposure.include. Additionally, I would prefer if no unexpected redirect to /swagger-ui were to happen and instead I can freely chose the actuator sub-path where the UI is offered – if possible defaulting to swaggerui.

Additional context
This question arises because when dealing with WebSecurityConfigs and (dis)allowing access to paths via e.g. ant-style matcher syntax the redirect to a third path complicates matters somewhat.

@bnasslahsen
Copy link
Contributor

@Okeanos,

All the path sprindoc-openapi properties are not applicable when springdoc.use-management-port=true.
This is related to @ControllerEndpoint where the path cannot be passed as variable / or from property file.

Not sure we could propose better, unless you have any PR.

@bnasslahsen bnasslahsen added the question Further information is requested label Apr 21, 2022
@Okeanos
Copy link
Author

Okeanos commented Apr 21, 2022

Just for clarities sake concerning springdoc.use-management-port=true:

  • /actuator/openapi hosts the actual OpenAPI json document
  • /actuator/swaggerui redirects to /actuator/swagger-ui
  • /actuator/swagger-ui serves the actual (or parts of?) the actual UI

What you are saying is that there is no (easy) way to unify /actuator/swaggerui and /actuator/swagger-ui?


Beyond that I would like what you describe to be documented in https://springdoc.org/#actuator-support (and/or https://springdoc.org/#properties ) because currently the documentation doesn't say that the prefix changes don't apply anymore.

@bnasslahsen
Copy link
Contributor

bnasslahsen commented Apr 21, 2022

@Okeanos,

For the actuator swagger-ui endpoint, you are asking for a breaking change. This might be doable and the impact should be evaluated, But as stated earlier it will not be configurable through properties.

You can test with latest SNAPSHOT and let me know if this is what you were expecting in terms of paths unification.

@bnasslahsen bnasslahsen added enhancement New feature or request and removed question Further information is requested labels Apr 21, 2022
@Okeanos
Copy link
Author

Okeanos commented Sep 17, 2022

@bnasslahsen sorry for not following up sooner here, I was swamped with work and apparently marked this notification as "read" without bothering to follow up. I just went through the changes you did. Thanks a lot, this looks like precisely what I was hoping for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants