Use IDEA plug-in to generate YaPi interface documents + Windows environment to build YaPi service

Use IDEA plug-in to generate YaPi interface documents + build YaPi service in Windows environment

[Note 1: Before using the idea plug-in to generate yapi documents, you need to set up a yapi service]
[Note 2: This article is about setting up the Yapi service on Windows]
[Note 3: It is best to keep the version of the following software installed consistent with mine. Higher versions of node will be incompatible with mongo]

Without further ado, let’s start arranging!

1, install node12:
Download:
Installation package link: https://nodejs.org/download/release/v12.18.3/

? Select this version and click to download:

img

Installation: [Basically the next step]

① Double-click the installation package to install directly: Next step

? ② Customized installation directory: [It is best not to use Chinese for the directory]

? ③Go directly to the next step:

? ④ Do not check, go to the next step:

? ⑤Click “install” to install:

? ⑥The installation is complete, click “finish”:

Check [Note: node will automatically configure environment variables]
#Use the shortcut key "win + r", enter "cmd" to bring up the command line window, and enter the following instructions in the window:
# node version
node -v
# npm version
npm -v

As shown in the picture: Installation successful

Install Taobao image:
#Enter the following instructions on the command line:
#Install Taobao image:
npm config set registry https://registry.npm.taobao.org
#Check if successful:
npm config get registry

As shown in the picture: the installation is successful:

2, install mongo4:
Download
Mongo official website link: https://www.mongodb.com/try/download/community

As shown in the picture: [You may need to register an account for the first installation, just follow the instructions to register]

Installation: [Basically the next step]

① Double-click the installation package to install directly: Next step

②Next step:

③Click “custom” and next step

④Customized installation directory: [It is best not to have Chinese characters]

⑤Confirm the directory, next step:

⑥Go directly to the next step:

⑦Cancel the check, next step:

⑧Installation successful:

Configure environment variables:

Step1: This computer (right-click)–>Properties–>Advanced system settings–>Environment variables

Step2: Create a new system variable–>path variable

Copy and paste the bin directory under the mongo installation directory:

Check:
Command: mongo -version

As shown in the picture: Installation successful

Start:

Create a db directory under the installation directory \data\ as an alternative directory to the installation directory \data\, and explicitly specify this directory as the storage location.

#Command
mongod.exe --dbpath "Your MongoDB installation directory\data\db"

As shown in the picture:

Verify whether startup is successful:
#Browser access:
http://localhost:27017/

As shown in the figure: Successful startup

3. Install Yapi:
npm installation: Note that this step only needs to be performed once. You can skip this step directly when starting the yapi service again in the future
#Enter the following instructions on the command line:
#Install
npm install -g yapi-cli --registry https://registry.npm.taobao.org
#start up:
Yapi server

As shown in the picture:

Verification:
#Browser access:
localhost:9090

As shown in the figure: Successful startup

Detailed explanation:

Deployment successful:

Start Yapi service:
#Enter the deployment directory just now and run the command prompt as an administrator:
cd C:\Windows\System32\my-yapi
#start up
node vendors/server/app.js

As shown in the figure: Successful startup

Verification:
#Browser access:
http://localhost:3000
#Default username: the email you just set Default password: ymfe.org

As shown in the picture:

New project:

After logging in, you need to create a project:

Project information: can be customized

After creation is complete:

Click to enter the project: pay attention to the location of this token

4. Install the plug-in in idea and configure Yapi service:
Install the plug-in: EazyYapi [You need to restart the idea for the first installation]

Configure Yapi service:

Generate interface document: Select the controller interface class for which interface document needs to be generated: right-click
[The premise is that the controller class must have already written interface methods]

Fill in the project token:

If you see this line of information in the idea console, it means success:

Yapi service view: [The same controller class corresponds to a folder, and on the right are all the interface methods in the class]

Export interface document:

After exporting, it is a file: such as a file in html format

Click to open: The right side is the directory, and the left side is the interface details (including interface name, request method, request path, request parameters, return value, etc.)

Similarly, files of specified types can also be imported, which will not be demonstrated here;

At this point, this article ends. . . .