An API management artifact pushed by Alibaba and Tencent!

Time:2022-6-20

An API management artifact pushed by Alibaba and Tencent!

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 efficientlyFor 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

  1. Using swagger to manage API documents
  2. Using the postman debugging API
  3. Use tools such as mockjs to mock API data
  4. 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.

  1. After swagger defines the document, the developer needs to go to postman to define it again during interface debugging.
  2. 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.
  3. The tester needs to go to JMeter to define it again.
  4. 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.
  5. Similarly, various inconsistencies will be found when the test cases written by JMeter are actually run.
  6. Over time, various inconsistencies will become more and more serious.

Apifox solutions

An API management artifact pushed by Alibaba and Tencent!

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

  1. interface design: the apifox interface document follows OpenAPI 3.0 (the original swagger) and JSON schema specifications, and provides a very usefulvisualizationDocument management function, zero learning cost, very efficient. It also supports online sharing of interface documents.
  2. data model: reusable data structures, defining interfacesReturn data structureandRequest 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.
  3. 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, clickSave as use caseButton to generateInterface use caseInterface 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.
  4. Interface use case: usually, an interface has multiple use cases, such asCorrect parametersUse casesParameter errorUse casesData is emptyUse casesDifferent data statusUse 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.
  5. 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 apifoxZero configurationYou can mock out very humanized data, which will be introduced later in this article.
  6. 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.
  7. 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.
  8. Quick debugging: similar to the interface debugging method of postman. It is mainly used for temporary debuggingNo documentation requiredIt can be quickly debugged without defining the interface in advance.
  9. code generation: automatically generated by the system according to the interface and data model definitionsInterface request codeFront end business codeandBack end business code
  10. TeamworkApifox is born for team collaboration. The interface cloud is updated in real time and matureTeam / project / member permissionsManagement 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!

An API management artifact pushed by Alibaba and Tencent!

4. Visualization settings assertion

Set assertion:

An API management artifact pushed by Alibaba and Tencent!

After running, view the assertion results:

An API management artifact pushed by Alibaba and Tencent!

5. Visualization settings extract variables

An API management artifact pushed by Alibaba and Tencent!

6. Support database operation

An API management artifact pushed by Alibaba and Tencent!

7. “Zero configuration” mock produces very user-friendly data

First, put a picture to compare apifox with other similar toolsZero configurationData effect from mock:

An API management artifact pushed by Alibaba and Tencent!

It can be seen that apifoxZero configurationThe 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 efficiencyZero configurationGenerate very humanized mock data

  1. Apifox automatically generates mock rules according to the data structure and data type in the interface definition.
  2. 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 stringimageofstringType field, automatically mock out a picture address URL; Include stringtimeofstringType field, automatically mock out a time string; Include stringcityofstringType field, automatically mock out a city name.
  3. 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.
  4. In addition to the built-in mock rules, users can also customize the rule library to meet various personalized needs. Support useregular expression wildcardTo 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.

An API management artifact pushed by Alibaba and Tencent!

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 templateTo generate code that meets the architectural specifications of your team and meets various personalized needs.

10. Import, export

  1. Support exportOpenApi (Swagger)MarkdownHtmlAnd other data formats, because they can be exportedOpenApiFormat data, so you can use OpenAPI (swagger) rich ecological tools to complete various interface related things.
  2. Support importOpenApi (Swagger)PostmanapiDocHARRAMLRAP2YApiEolinkerNEIDOCleverApiPostApizzaShowDocAPI BlueprintI/O DocsWADLGoogle DiscoveryAnd other data formats to facilitate the migration of old projects.
  3. supportTimed AutoImportOpenApi (Swagger)apiDocApifoxFormat data.

3、 Subsequent function planning

  1. Release the web version of apifox, and support the use of apifox on the browser side.
  2. Interface performance test support (similar to JMeter).
  3. Support the plug-in market, and you can develop your own plug-ins.
  4. Open the apifox API, allowing developers to call the functions of apifox through the API.
  5. Support more interface protocols, such asGraphQLgRPCwebsocketEtc.
  6. It supports offline use. Projects can be synchronized online (team collaboration) or only stored locally (single machine offline).

Recommended Today

[mybatis series] understand mybatis field mapping hump naming from the perspective of source code

In the previous blog -[[jdbc] handle resultset and build Java objects]( https://my.oschina.net/kailun… As mentioned in, we need to analyze three things that mybatis does when converting results to required Java business objects, as follows: It solves the mapping from database column names to Java column names. The conversion from database type to Java type is […]