All About Swagger
I, Arsalan MirBozorgi, want to talk to you about Swagger. Swagger is actually a framework designed to fully define an agnostic language as an interface to REST IP. Agnostic languages have a lot of flexibility and allow you to do everything you expect them to do. Note that this framework allows the computer as well as the programmer to access the capabilities of the services without access to the source code or Internet traffic. If the Swagger is defined correctly, the user can notice the remote services with the least amount of logical implementation and interact with them directly. The interpreter removes the guessing part of the service call, as interfaces do for lower-level languages. If we want to speak more specifically in this field, we must say that Swagger is a very efficient and formal tool that is surrounded by other very large and complex categories and includes all sections of the user interface in front-end EPI and libraries containing low-level code.
Example of Swagger dependencies
First, we add the following which we need to maven to get started.
In the next level, we create the following package and class.
Pay attention to the SwaggerConf class.
Pay Attention to #1 and *1 marked with red boxes. The phrase “com” is the name of the package that contains all the packages and classes.
Pay attention to #2 and *2 marked with purple boxes. All the controllers of this program start with the address /rest/ and then the expressions / rest/courses and /rest/ teacher are added. For this reason, we use *.reset/ . Note the Configuration and EnableSwagger2 notations in the SwaggerConf class.
In the next step, we create a port for the project and then create the project. For this purpose, we first go to http://localhost:8080/swagger-ui.html and follow the steps according to the following 3 images.
In this level, in the SwaggerConf class, make changes as shown below.
That these changes are visible in the following 2 images.
At this point we go to the CourseController class.
After going to the CourseController class, type @Api at the top of the insert method. In this case, some suggestions are displayed for us.
You can then see the changes made.
The following image is also another example.