• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

How can I have Spring print out all web api endpoint details?

 
Sheriff
Posts: 4633
300
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Spring Boot app and part of the log output during startup looks like this:

Is there a maven goal for Spring or something that I can use to print this information? I'd like to be able to easily script an up to date report of my current api.
 
Greenhorn
Posts: 4
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be you should take a look into spring boot actuators. It provides many endpoints out of the box.
 
Sheriff
Posts: 21759
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can find the out-of-the-box actuators at https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html. In this case, the mappings one seems to be what you need, but its output is quite verbose.
 
Tim Cooke
Sheriff
Posts: 4633
300
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had not heard of Actuators before so that's good information. However, I must be trying to access it incorrectly or my app has them disabled because hitting this just returns 404
 
Dhiraj Ray
Greenhorn
Posts: 4
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check if you have the right dependency included in your pom.xml or else visit https://www.devglan.com/spring-security/securing-spring-boot-actuator-endpoints-with-spring-security for actuator configuration and accessing actuator endpoints.
 
Tim Cooke
Sheriff
Posts: 4633
300
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did not have the right dependency. Now I do and it's working a treat! Thanks Dhiraj
 
Marshal
Posts: 6851
470
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also you could use your Spring Boot app along with Swagger, which could be used for auto built RESTful API docs:

And having defined configuration in your Spring Boot app:

Access documentation: REST-URL:PORT/swagger-ui.html <-- could map to something more descriptive of course.

Not exactly sure whether it is what you are looking for though.
 
Tim Cooke
Sheriff
Posts: 4633
300
IntelliJ IDE Clojure Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras, if I were in London right now I'd come round your house and hug you.

This is perfect! Thank you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!