This is the 8th day of my participation in the More text Challenge. For details, see more text Challenge

YDoc1.0.4 supports microservices, automated testing, and notifications

Update the content

  1. Fix 1.0.3 out of sync bug
  2. Support for microservices, where multiple services are used within a YApi project
  3. Support for triggering automated tests at startup and printing reports
  4. Support for automated test nail notifications

Use the version 1.0.6 maven address

Source code has been open source to Github welcome to contribute source code, like a Star support

YDoc1.0.4 parameters

1. Support microservices

With multiple microservice projects, we don’t want each microservice to own a separate YApi project, so just configure the same yapi.token, host, and enable the following parameters to synchronize both swagger native and YDoc generated documents. If there is duplication of the ControllerAPI in multiple microservices, it is automatically merged into one Api category and will not be overridden.

Ydoc. cloud=trueCopy the code

Let’s start two microservices and duplicate their ApiTag to see if they collide and are overridden

//YDoc schema @restController (value = "user related ") // Native Swagger schema @api (tags =" user related ") public Class TestController {// Native Swagger schema @postMapping (value = "/post/A",name = "/post/A") public User test1(@requestBody User)  user){ System.out.println(user); return user; }} -- //YDoc schema @restController (value = "user related ") // Native Swagger schema @api (tags =" user related ") public class TestController { //YDoc schema @postMapping (value = "/post/B",name = "/post/B") public User test1(@RequestBody User user){ System.out.println(user); return user; }}Copy the code

Start the two projects separately to view YApi, and the results will not be overwritten.

2. Support automated testing

To enable automated testing, you need to configure the following parameters. When the program is started, the set of tests configured on YApi will be tested against the rules configured on YApi (it is recommended to use this feature after configuring mock parameters and assertions)

The name of the test collection group must be in English because it needs to be written in the configuration file. Chinese can have garbled characters

There are a few parameters to enable automated testing. Some apis are not open due to some reasons of YAPI, so you need to configure the user name and password used to obtain the token.

# Project ID can be seen in project Settings, Ydoc. test-name=test1,test2 Ydoc. yapi-user-password= XXXXXX; ydoc.yapi-user-password= XXXXXXCopy the code

At this point we launch the project and can see the API information and results tested by the automated test in the log.

16:44:00 2021-06-22. 39493-177 the INFO [task - 1]. Com. Making ydoc. Config. YapiApi: ydoc test automation test1api is as follows: 16:44:00 2021-06-22. 39493-177 the INFO [task - 1]. Com. Making ydoc. Config. YapiApi: API: [A micro service user related] path: [/ post/A] 2021-06-22 16:44:00. 39493-177 the INFO com [task - 1]. The dead simple. Ydoc. Config. YapiApi: A total of 1 test case, all validation through the elapsed time: 0.011 s 16:44:00 2021-06-22. 39493-623 the INFO com [task - 1]. The dead simple. Ydoc. Config. YapiApi: YDoc test automation test2api is as follows: the 2021-06-22 16:44:00. 39493-623 the INFO] [task - 1 com. Making. YDoc. Config. YapiApi: API: Path: [B micro service user related] [/ post/B] 16:44:00 2021-06-22. 39493-623 the INFO com [task - 1]. The dead simple. Ydoc. Config. YapiApi: A total of 1 test cases, all verified by the consumption time :0.016sCopy the code

2. Test push of nails

# Obtain ydoc. Access-token = XXXXXXXXX through the Nail Swarm robotCopy the code

Since we have two test sets configured above, one message will be pushed separately.