As a software development practitioner, API debugging is an essential skill, and postman has done very well in this regard.
However, API debugging is only a part of the whole software development process, and there are still many things that postman cannot complete, orUnable to complete efficiently
For example, API document definitions, API mock, API automated testing, and so on. Apifox was born to solve this problem.
Interface management status
1、 Common solutions
- Using swagger to manage API documents
- Using the postman debugging API
- Use tools such as mockjs to mock API data
- Use JMeter for API automation test
2、 Existing problems
Maintaining data consistency between different tools is very difficult and inefficient. Moreover, it is not only the workload problem, but also the data inconsistency between multiple systems, which leads to inefficient collaboration, frequent problems, and the pain of developers and testers.
- After swagger defines the document, the developer needs to go to postman to define it again during interface debugging.
- When developing mock data at the front end, you need to define it in mockjs again, and you also need to set the mock rules manually.
- The tester needs to go to JMeter to define it again.
-
The front end was developed based on the data from mockjs mock, and the back end was developed based on the interface documents defined by swagger. Both of them passed the test. I thought they could go online immediately. As a result, various problems were found as soon as they were connected:
- During the development process, the interface was changed. Only swagger was modified, but mockjs was not synchronously modified in time.
- The interface data type of the back-end development is inconsistent with the document, so it is difficult to find the problem with the naked eye.
- Similarly, various inconsistencies will be found when the test cases written by JMeter are actually run.
- Over time, various inconsistencies will become more and more serious.
Apifox solutions
1、 How to solve these problems
1. Apifox positioning
Apifox = Postman + Swagger + Mock + JMeter
Apifox is an integrated collaboration platform for API documentation, API debugging, API mock, and API automated testing.
Through a set of systems and a copy of data, the problem of data synchronization between multiple systems can be solved. As long as the interface document is defined, interface debugging, data mock and interface test can be used directly without redefining; The same tool is used for interface document and interface development and debugging. After interface debugging is completed, it can be guaranteed to be completely consistent with the definition of interface document. Efficient, timely and accurate!
2. Apifox purpose
Save every minute of the R & D team!
3. Apifox function
- interface design: the apifox interface document follows OpenAPI 3.0 (the original swagger) and JSON schema specifications, and provides a very useful
visualization
Document management function, zero learning cost, very efficient. It also supports online sharing of interface documents. - data model: reusable data structures, defining interfaces
Return data structure
andRequest parameter data structure
(JSON and XML schemas only) can be referenced directly. It supports direct nested reference of models, direct json/xml intelligent import, and advanced composite modes such as oneof and allof. - Interface commissioning: apifox has some postman functions, such as environment variables, pre / post scripts, cookie/session global sharing, and is more efficient and easy to use than postman. After the interface runs, click
Save as use case
Button to generateInterface use case
Interface use cases can be run directly in the future without entering parameters, which is very convenient. The custom script is 100% compatible with postman syntax, and supports running various language codes such as JavaScript, Java, python, PHP, JS, BeanShell, go, shell, ruby, Lua, etc. - Interface use case: usually, an interface has multiple use cases, such as
Correct parameters
Use casesParameter error
Use casesData is empty
Use casesDifferent data status
Use cases, etc. The correctness of data will be automatically verified when running interface use cases. It is very efficient to debug interfaces with interface use cases. - Interface data mock: built in mock JS rule engine is very convenient to mock various data, and can write mock rules while defining the data structure. Add “expectation” and return different mock data according to the request parameters. The most important thing is apifox
Zero configuration
You can mock out very humanized data, which will be introduced later in this article. - Database operation: it supports reading database data as interface request parameters. It supports reading database data to verify (assert) whether the interface request is successful.
- Interface automation test: provides interface set tests. You can quickly create test sets by selecting interfaces (or interface use cases). At present, more functions of interface automation test are still under development. Please look forward to it! The goal is that JMeter will basically have some functions, and it should be better used.
- Quick debugging: similar to the interface debugging method of postman. It is mainly used for temporary debugging
No documentation required
It can be quickly debugged without defining the interface in advance. - code generation: automatically generated by the system according to the interface and data model definitions
Interface request code
、Front end business code
andBack end business code
。 - TeamworkApifox is born for team collaboration. The interface cloud is updated in real time and mature
Team / project / member permissions
Management to meet the needs of various enterprises.
Recently, I sorted out a set of programming learning materials to share with you. They are all dry goods, including tutorial videos, e-books, source code notes, learning roadmap, practical projects, interview questions, etc. you can get them for free by following GZH [Python Programming learning circle], and reply to the keyword [learning materials]. Hurry up!
2、 Apifox does more than just get through the data
If you think that apifox only makes data communication to improve the efficiency of the R & D team, you are wrong. Apifox has also made many innovations to improve the efficiency of developers.
1. Interface supports “use case management”
Usually, an interface has multiple use cases, such asCorrect use case
Parameter error case
Case with empty data
Different data status use cases
。 These use cases in different states are defined when defining the interface, and they are run directly when debugging the interface, which is very efficient.
2. Definition and reference of “data model”
Data models can be defined independently. Data models can be directly referenced during interface definition, and data models can also be referenced each other. The same data structure can be used in multiple places only by defining it once; When modifying, only one place needs to be modified, and multiple places need to be updated in real time to avoid inconsistency.
3. “Auto check” data structure during debugging
When using apifox to debug an interface, the system will automatically verify whether the returned data structure is correct according to the definition in the interface document. There is no need to identify it with the naked eye or write an assertion script manually. It is very efficient!
4. Visualization settings assertion
Set assertion:
After running, view the assertion results:
5. Visualization settings extract variables
6. Support database operation
7. “Zero configuration” mock produces very user-friendly data
First, put a picture to compare apifox with other similar toolsZero configuration
Data effect from mock:
It can be seen that apifoxZero configuration
The data from mock is very close to the real situation. Front end development can be used directly without writing mock rules manually.
How apifox does ithigh efficiency
、Zero configuration
Generate very humanized mock data
- Apifox automatically generates mock rules according to the data structure and data type in the interface definition.
- The built-in intelligent mock rule library in apifox intelligently optimizes the automatically generated mock rules according to the field name and field data type. For example, the name contains a string
image
ofstring
Type field, automatically mock out a picture address URL; Include stringtime
ofstring
Type field, automatically mock out a time string; Include stringcity
ofstring
Type field, automatically mock out a city name. - According to the built-in rules, apifox can automatically identify the fields such as picture, avatar, user name, mobile number, website, date, time, timestamp, email, province, city, address, IP, etc., so as to mock out very humanized data.
- In addition to the built-in mock rules, users can also customize the rule library to meet various personalized needs. Support use
regular expression
、wildcard
To match custom mock rules for field names.
8. Generate online interface document
Apifox project can “share” API documents online. The shared API documents can be set to be public or require password access, which is very convenient for collaboration with external teams.
9. Automatic code generation
Automatically generate business code (such as model, controller, unit test code, etc.) and interface request code of various languages / frameworks (such as typescript, Java, go, swift, objectivec, kotlin, dart, c++, c\. At present, apifox supports automatic code generation for 130 languages and frameworks.
More importantly, you canCustom code template
To generate code that meets the architectural specifications of your team and meets various personalized needs.
10. Import, export
- Support export
OpenApi (Swagger)
、Markdown
、Html
And other data formats, because they can be exportedOpenApi
Format data, so you can use OpenAPI (swagger) rich ecological tools to complete various interface related things. - Support import
OpenApi (Swagger)
、Postman
、apiDoc
、HAR
、RAML
、RAP2
、YApi
、Eolinker
、NEI
、DOClever
、ApiPost
、Apizza
、ShowDoc
、API Blueprint
、I/O Docs
、WADL
、Google Discovery
And other data formats to facilitate the migration of old projects. - support
Timed Auto
ImportOpenApi (Swagger)
、apiDoc
、Apifox
Format data.
3、 Subsequent function planning
- Release the web version of apifox, and support the use of apifox on the browser side.
- Interface performance test support (similar to JMeter).
- Support the plug-in market, and you can develop your own plug-ins.
- Open the apifox API, allowing developers to call the functions of apifox through the API.
- Support more interface protocols, such as
GraphQL
、gRPC
、websocket
Etc. - It supports offline use. Projects can be synchronized online (team collaboration) or only stored locally (single machine offline).