no

Localization and Swagger Documentation

Go Back to Course Outline Two of the most commonly used beans when developing a RESTful web service are localization and swagger. Loca...


Go Back to Course Outline

Two of the most commonly used beans when developing a RESTful web service are localization and swagger. Localization allows us to translate messages from one language to another by passing the accept-language header in the request. While swagger helps us in documenting our REST APIs with the use of annotations.

Let’s see them in action.

First, add the dependency on maven pom file [show the pom file]
Create the localization and swagger configuration, don’t forget to annotate the classes with @Configuration so that Spring will pick them up.

Then create the category controller for testing [show the CategoryController class]

Notice that we use swagger classes to annotate the endpoint and the method. These will be shown in the auto-generated documentation later.

[demo http://localhost:8080/swagger-ui.html]
[demo http://localhost:8080/categories/hello in postman]

Related

coding 4235149907996707816

Post a Comment Default Comments

item