Many interface management tools are springing up. Thankfully, there are many excellent works from China, including YApi and RAP.
Looking at the Chinese official website, familiar Chinese, can not help but let a person dark cool. Of course, this leads to another disadvantage, because of the low base, so there are few references. If we want to learn how to use it, we have to rely on official documentation, which is a blessing or a curse.
This article will take you into the world of Yapi and give you a taste of a refreshing interface management tool.
1
According to statistics, there are more than 1 billion Internet projects on the market, and the number of apis involved by conservative statistics is 10 billion. But many apis are of questionable quality. Because apI-related documentation, debugging, testing, and data mocks are very inefficient at work.
We desperately need a product that has interface management capabilities, debugging, document management and testing capabilities. Then YApi came out of nowhere.
It is an interface management platform that helps developers create, publish, and maintain apis. YApi also provides excellent interactive experience for users. Developers only need to use the platform to provide interface data writing tools and simple click operations can achieve interface management.
The image is from YApi website
YApi installation is not piecemeal, you need to download the mongoDB database and then deploy it. Due to the limited space in this article, I will not show the specific installation process.
2
Like RAP, Swagger, and MoCO, YApi is suitable for companies with complex businesses, especially when they collaborate across departments.
Rap also has a graphical interface, but is losing popularity to YAPI. Swagger, on the other hand, is a super powerful tool whose ambitions go beyond interface management, and we’ll talk about it later.
Moco won the Duke Choice Award in 2013, and moco is easy to use: maintain a JSON file and run it from a command.
In the face of so many tools, YApi stands out from the crowd. In practice, YApi and Swagger belong to two schools, the former is easy to manage and has a friendly UI interface, but weak ecology, relying on manual and UI maintenance. Swagger, on the other hand, is an ambitious man who has provided a full life cycle solution to the API, which is no longer a tool, but a standard.
3
After entering YApi, this page, this UI, is really small and fresh, worthy of the up-and-comer. Here is a brief introduction, which mainly consists of the following four parts:
-
The head of the home page shows the current location, search box, new project, view documents and user information.
-
Group information is displayed on the left of the home page. Group information is a collection of items. Only the super administrator can manage groups.
-
The right side of the home page is the list of projects and members under the group. Click a group on the left, and the project and member information under the group will appear on the right side.
-
Click the star in the upper right corner of the project to follow the project, the project can be viewed in the “My Concerns” page.
In fact, not only the homepage UI, his project UI is also amazing, in UI such a fresh domestic platform has been very rare.
4
Click on a project to take you to the project page, which shows all the interfaces that belong to that project. It also provides all operations of projects and interfaces.
-
Interface List on the left of the project page displays all interfaces under the project. By default, the list of all interfaces under the project page is displayed on the right.
-
Click on an interface on the left, and “Preview”, “Edit” and “run” will appear on the right.
-
Click “Test Set” on the left to use the test set function.
-
Click “Settings” in the secondary navigation, and the project leader can edit the project information and manage the list of members.
-
Click “Dynamic” in the second-level navigation to view the operation logs of the project.
5
Some readers can’t wait! To get started with YApi, use a simple example. When you create an interface in your project, a window pops up with several options. What is the interface path? This is convenient for the front end to call the back end while setting the interface path:
Click the newly added interface. The preview information of the interface is displayed on the right. Click Edit on the right to enter the edit panel. In this panel you can see the basic interface information (interface name, category, path), in addition to you can also refine the following interface information:
-
Interface path: You can change the HTTP request mode and support restful dynamic routes, such as/API /{id}/{name}. Id and name are dynamic parameters
-
Status: Indicates whether the interface has been developed.
-
Tag: Identifies the Tag information of an interface (v1.3.23+). You can filter interfaces based on the Tag information on the interface list page
Moving on, you’ll see the request parameters, which can be required or not required for a request:
-
Query parameter: the Query string of the INTERFACE URL. Click the “Add Query Parameter” button to add parameters, and drag to swap parameter positions
-
Headers: HTTP request header field. In req_body format, ‘Content-Type Application/X-www-form-urlencoded ‘will be automatically generated in the header, and different headers will be automatically generated in the other three formats
The request parameters are followed by the return data, which comes in json and RAW forms. Based on MockJS and Json5, this is a way to write parameters using comments. If you don’t understand Mock, please note the link below.
The Mock is introduced:
https://hellosean1025.github.io/yapi/documents/mock.html
The above is just the interface Settings, but we often encounter situations where I want to return different HTTP codes, HTTP headers, and JSON data based on different request parameters, IP, and so on. The interface Settings cannot be done. It said, “Stand aside, I can do it!”
6
Expectation mocks, which can return expected data based on request filtering rules, are a high-end player. To use it, go to the Interface details page and click Advanced Mock.
Click Add Expectation, fill in filtering rules and expected return data, as shown below, and click OK.
Let’s test it in the browser and send a request that matches the rule:
7
As I said, it’s not easy for YApi to stand out from the crowd. In practice, YApi and Swagger belong to two schools. The former is easy to manage and has a friendly UI, but is weak in ecology and relies on manual and UI maintenance. Swagger, on the other hand, is an ambitious man who has provided a full life cycle solution to the API, which is no longer a tool, but a standard.
YApi has a long way to go, and it has its own rival: Swagger. Due to limited space, this article will be covered for the time being. For more exciting content, please follow the Hogwarts Test House official account.
– Today interactive –
Feel free to leave a comment below and share with other testers
(Don’t forget to long press and add the assistant wechat: ihorgwarts001
Reply “10th issue” to join the group exchange oh ~)