What is Swagger?
All About Swagger
I’m Arslan Mirbzergi,
in this article I’m going to talk to you about Swagger. Swagger is actually a framework created with the aim of defining an agnostic language (agnostic languages are so flexible that they can do all the work you expect them to do for you) as the interface with REST APIs. This framework allows the computer and the person to access the capacities of the Services without access to source code, files or Internet traffic. If Swagger is defined correctly, the user can remote service and interact with it using the lowest amount of logigator implementation. Swagger removes the guessing section in the service call, such as what interfaces do for lower-level languages. More specializedly, swagger is an efficient and formal tool surrounded by a large bunch of other tools and includes all sections of the interface in Front End, libraries containing low-level codes and commercial and managerial APIs.
Example of Swagger dependencies
First, we add the following to maven to get started.
Next, we create the following class and package.
Pay attention to the SwaggerConf class.
Pay attention to the #1 and *1 marked with red boxes. The phrase “com” is the name of the package where all packages and classes are located.
Pay attention to the #2 and *2 marked with purple boxes. All controllers in this program are started with /rest/ and then the phrases /rest/courses and /rest/teacher are added. That’s why from/rest.*we use.Pay attention to configuration and EnableSwagger2 annotations in the SwaggerConf class.
In the next step, we create a port for the project and create the project, so first we go to the http://localhost:8080/swagger-ui.html address and follow the steps according to the following 3 images.
In this step, in the SwaggerConf class, we will apply 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 at the top of the insert method, we type @Api. In this case, some suggestions will be displayed for us.
Among the suggestions displayed, we select ApiOperation@.
You can then see the changes made.
The following image is also another example.