ManagePeople API

The ManagePeople web service example uses  Spring Framework, Apache CXF, Swagger UI, and embedded  Jetty. Integrating Swagger is a matter of adding configuration bean ( swaggerConfig ), one additional  JAX-RS service ( apiListingResourceJson ) and two  JAX-RS providers (resourceListingProvider and apiDeclarationProvider ). The example is liberally adapted from the following public domain information: Swagger: Make Developers Love Working With Your REST API

In order to get rid of any possible hard-coded configuration, all parameters are passed through named properties (SERVER_PORT, SERVER_HOST, and CONTEXT_PATH). Swagger exposes additional REST endpoint to provide API documentation, in our case, it is accessible at http://localhost:8080/rest/api/api-docs. It is used by Swagger UI which itself is embedded into final JAR archive and served by Jetty as a static web resource.

The final piece of the puzzle is to embed Jetty container which glues all those parts together and is encapsulated into the Starter class:

The main intent is not to focus on the implementation so much but on understanding how to add API Open Specification reference documentation to the code itself.

See also

References

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.