background

Due to the business expansion needs of the company, the project team and project gradually increased, coupled with the need to create a data center, an OpenAPI system similar to Taobao API is urgently needed, so that the data center can provide interfaces and services for other downstream systems. After comparing several similar systems, YApi was finally selected for transformation and development.

Why YApi

Swagger is often the first thing that comes to mind when talking about OpenAPI. Although Swagger has quite powerful functions and is easy to integrate with existing Spring framework projects, its English-only interface cannot be called friendly. Then he turned his attention to various open source projects, including many OpenAPI systems with high appearance and light weight:

A comparative multiple class Swagger framework’s blog: www.jianshu.com/p/1761449dd…

However, after comprehensive consideration, I chose YApi for the following reasons:

  1. High level of appearance, friendly interface: a lot of people use things after all it can not be too ugly, easy to use is
  2. Powerful: It integrates THE FUNCTIONS of Api browsing, testing (supporting Mock), import and export. The interface is easy to manage and maintain. It also has the function of interface permission management and plug-in mechanism, basically covering most operations about the interface
  3. Operation friendly: Apache open source agreement, can use online version can also be deployed offline; Independent deployment, separated from the service system, and support Swagger import, Postman import and other import forms, easy to maintain the existing system API in, can also be manually added to the maintenance interface, convenient and flexible
  4. Open source, well-documented: official documentation is complete, and search engines have a lot of information about it; It is said that many Internet giants are also using it

Of course, it also has some disadvantages:

  1. The directory level has only one level, which is not friendly to complex service systems.
  2. Users can be added only through registration. The administrator cannot create users or new administrators.
  3. Hardbind Mongodb to add deployment overhead.
  4. The last version of Github was 19 years old, and many popular issues have not been modified.

Despite the flaws, YApi is still an excellent API management platform, and we, as programmers, can change it if we don’t like it

YApi official document: hellosean1025. Making. IO/YApi /

Set up the deployment

Before setting up, we need to prepare the following environment:

  • Nodejs (+ 7.6)
  • Directing (+ 2.6)

Then, without delay, deploy to see Mount Tai in action:

The official deployment document: hellosean1025. Making. IO/yapi/conversation…

Here I try to integrate the interpretation:

Mode 1 Visual Deployment (official recommendation)

NPM install - g yapi - cli - the registry https://registry.npm.taobao.org yapi server node deployment {path} / server/app. JsCopy the code

The advantage of this method is that it can be deployed on a visual interface without complex commands and steps to modify configuration files. The disadvantage is that yAPi-CLI cannot be installed on the Intranet when the network is disconnected

Mode 2 Cli Deployment (recommended by the author)

  1. Download the source code: You can use git Clone or download the ZIP and decompress it, and the core is the vendors directory code (the same goes for downloading others’ modified code)

Official Git address: github.com/YMFE/yapi.g…

  1. Copy and modify configuration files: Copy config_example.json from the vendors directory to an outer layer, the vendors directory, and change the vendors name to config.json, and modify the parameters as needed.

– The following operations are all done under vendors directory:

  1. Install dependencies
npm install --registry https://registry.npm.taobao.org
Copy the code
  1. Initial configuration, initialization of the database, automatic database building table
npm run install-server 
Copy the code

These four steps are equivalent to the first two steps of approach 1 visual deployment. At this point, the project has been initialized and only needs to be started

  1. Start the service
node server/app.js
Copy the code

After the system is successfully started, access localhost:{configured port} to open the system. The port deployed in mode 1 is configured when filling in the web form, and you can modify the configuration file later. The ports deployed in mode 2 are in config.json

Login system

If not, the following interface will be displayed after login:

Start your YApi journey with your initial user password: admin/ymfe.org