Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • 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
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

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

 
Marshal
Posts: 4856
317
IntelliJ IDE Python Java Linux
  • 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: 21919
106
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
Marshal
Posts: 4856
317
IntelliJ IDE Python Java Linux
  • 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
Marshal
Posts: 4856
317
IntelliJ IDE Python Java Linux
  • 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
 
Sheriff
Posts: 7602
521
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
Marshal
Posts: 4856
317
IntelliJ IDE Python Java Linux
  • 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.
 
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic