### GET Request Example Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection.txt Example of a GET request to retrieve user control name. Includes setting an authentication token in the environment. ```json { "name": "current ctrl name-Example", "originalRequest": { "method": "GET", "description": "", "header": [ { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "url": { "path": [ "user", "ctrl", "name" ], "query": [], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/ctrl/name" } }, "code": 200, "_postman_previewlanguage": "json", "header": [ { "name": "date", "key": "date", "value": "Sun, 11 Apr 202106:56:34 GMT", "description": "The date and time that the message was sent" }, { "name": "server", "key": "server", "value": "Apache-Coyote/1.1", "description": "A name for the server" }, { "name": "transfer-encoding", "key": "transfer-encoding", "value": "chunked", "description": "The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity." }, { "name": "content-type", "key": "content-type", "value": "application/json;charset=UTF-8" } ], "body": "" } ``` -------------------------------- ### Create User Response Example Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.GenericMethodPostmanApiExporterTest.txt An example of a successful response after creating a new user. ```json { "code": 0, //response code "msg": "", //message "data": { "id": 0, //user id /** * user type * 1 :administration * 2 :a person, an animal or a plant * 3 :Anonymous visitor */ "type": 0, "name": "", //user name "age": 0, //user age "sex": 0, "birthDay": "", //user birthDay "regtime": "" //user regtime } } ``` -------------------------------- ### User Page Query API Example (GET with Array Response) Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.DirectorySpringMarkdownApiExporterTest.txt Demonstrates a GET request that returns a list of user objects. Includes the detailed structure of the array elements. ```json { "code": 0, "msg": "", "data": [ { "id": 0, "type": 0, "name": "", "age": 0, "sex": 0, "birthDay": "", "regtime": "" } ] } ``` -------------------------------- ### Install EasyApi Plugin from Source Source: https://github.com/tangcent/easy-yapi/blob/master/docs/knowledge-base/usage-guide.md Use this bash script to build the EasyApi plugin from its source code if you need to perform a manual installation. ```bash git clone https://github.com/tangcent/easy-yapi.git cd easy-yapi ./gradlew buildPlugin # The plugin zip is in build/distributions/ # Install via Settings → Plugins → ⚙ → Install Plugin from Disk ``` -------------------------------- ### POST Request Example Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection.txt Example of a POST request to add a user. Includes setting the Content-Type and authentication token in the headers, and a JSON body. ```json { "request": { "description": "", "header": [ { "key": "Content-Type", "value": "application/json", "type": "text", "description": "" }, { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "method": "POST", "body": { "mode": "raw", "options": { "raw": { "language": "json" } }, "raw": "{\n \"id\": 0,\n \"type\": 0,\n \"name\": \"\",\n \"age\": 0,\n \"sex\": 0,\n \"birthDay\": \"\",\n \"regtime\": \"\"\n}" }, "url": { "host": [ "{{test_default}}" ], "path": [ "user", "add" ], "raw": "{{test_default}}/user/add", "query": [] } }, "response": [ { "name": "create an user-Example", "originalRequest": { "method": "POST", "description": "", "header": [ { "key": "Content-Type", "value": "application/json", "type": "text", "description": "" }, { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "body": { "mode": "raw", "options": { "raw": { "language": "json" } }, "raw": "{\n \"id\": 0,\n \"type\": 0,\n \"name\": \"\",\n \"age\": 0,\n \"sex\": 0,\n \"birthDay\": \"\",\n \"regtime\": \"\"\n}" }, "url": { "host": [ "{{test_default}}" ], "path": [ "user", "admin", "add" ], ``` -------------------------------- ### Create User Example Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeUpdatePostmanApiExporterTest.collection-123456789.txt This snippet shows an example of creating a user with a predefined response structure. It includes headers and a JSON body with fields for user details. ```json { "code": 0, //response code "msg": "", //message "data": { "id": 0, //user id /** * user type * 1 :administration * 2 :a person, an animal or a plant * 3 :Anonymous visitor */ "type": 0, "name": "", //user name "age": 0, //user age "sex": 0, "birthDay": "", //user birthDay "regtime": "" //user regtime } } ``` -------------------------------- ### Postman GET Request Example Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection-original-collection.txt Example of a GET request with headers and a JSON response body. Includes prerequest and test event scripts. ```json { "name": "get user info", "event": [ { "listen": "prerequest", "script": { "exec": [ "pm.environment.set(\"token\", \"123456\");" ], "type": "text/javascript" } }, { "listen": "test", "script": { "exec": [ "pm.test(\"Successful POST request\", function () {", "pm.expect(pm.response.code).to.be.oneOf([201,202]);", "});" ], "type": "text/javascript" } } ] } ``` -------------------------------- ### PmVariableScope API Examples Source: https://github.com/tangcent/easy-yapi/blob/master/skills/easy-yapi-assistant/docs/easyapi-script-reference.md Demonstrates common operations for managing variables within different scopes like environment, globals, or collection variables. Includes checking existence, getting, setting, and removing variables. ```groovy // Check existence pm.environment.has("token") // → true/false // Get a value pm.environment.get("token") // → "abc123" or null // Set a value pm.environment.set("token", "abc123") // Get all variables as a Map pm.environment.toObject() // → ["token": "abc123", "host": "api.example.com"] // Remove a variable pm.environment.unset("token") // Clear all variables in this scope pm.environment.clear() // Resolve dynamic variables in a string ({{"$randomInt"}}, {{"$timestamp"}}, etc.) pm.environment.replaceIn("User-{{"$randomInt"}}") ``` -------------------------------- ### Install EasyYapi Skill Source: https://github.com/tangcent/easy-yapi/blob/master/README.md Installs the EasyYapi skill globally using npx. This allows AI assistants to invoke the skill for authoring EasyApi rules. ```bash npx skills add tangcent/easy-yapi -g -y ``` -------------------------------- ### Postman POST Request Example Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection-original-collection.txt Example of a POST request to create a new user, including headers, a raw JSON body, and URL parameters. ```json { "request": { "method": "POST", "description": "create a new user", "header": [ { "key": "Content-Type", "value": "application/json", "type": "text", "description": "" }, { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "body": { "mode": "raw", "options": { "raw": { "language": "json" } }, "raw": "{\n \"id\": 0, //user id\n /**\n * user type\n * 1 :administration\n * 2 :a person, an animal or a plant\n * 3 :Anonymous visitor\n */\n \"type\": 0,\n \"name\": \"\", //user name\n \"age\": 0, //user age\n \"sex\": 0,\n \"birthDay\": \"\", //user birthDay\n \"regtime\": \"\" //user regtime\n}" }, "url": { "path": [ "user", "create" ], "query": [ { "key": "id", "value": "0", "equals": true, "description": "user id" } ], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/add" } }, "response": [ { "originalRequest": { "method": "POST", "description": "", "header": [ { "key": "Content-Type", "value": "application/json", "type": "text", "description": "" }, { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "body": { "mode": "raw", "options": { "raw": { "language": "json" } }, "raw": "{\n \"id\": 0, //user id\n /**\n * user type\n * 1 :administration\n * 2 :a person, an animal or a plant\n * 3 :Anonymous visitor\n */\n \"type\": 0,\n \"name\": \"\", //user name\n \"age\": 0, //user age\n \"sex\": 0,\n \"birthDay\": \"\", //user birthDay\n \"regtime\": \"\" //user regtime\n}" }, "url": { "path": [ "user", "add" ], "query": [] } } } ] } ``` -------------------------------- ### Postman GET Request Example Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsWithWrapCollection.txt A simple Postman GET request example with a description indicating it does not update anything. ```json { "request": { "method": "GET", "description": "not update anything", "header": [], "url": { "path": [ "user", "greeting" ], "query": [], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/greeting" } }, "response": [ { "name": "say hello-Example", "originalRequest": { "method": "GET", "description": "not update anything", "header": [], "url": { "path": [ "user", "greeting" ], "query": [], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/greeting" } }, "code": 200, "_postman_previewlanguage": "json", "header": [ { "name": "date", "key": "date", "value": "Sun, 11 Apr 202106:56:34 GMT", ``` -------------------------------- ### User Profile Settings Response Example Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.SpringMarkdownApiExporterTest.txt Example JSON response structure for the user profile settings API, detailing user information such as ID, type, name, age, and registration time. ```json { "code": 0, "msg": "", "data": { "id": 0, "type": 0, "name": "", "age": 0, "sex": 0, "birthDay": "", "regtime": "" } } ``` -------------------------------- ### say hello Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeCopyPostmanApiExporterTest.txt This endpoint is used to send a greeting. It is a GET request to the /user/greeting path. ```APIDOC ## GET /user/greeting ### Description Sends a simple greeting message. ### Method GET ### Endpoint /user/greeting ### Response #### Success Response (200) - **body** (string) - A greeting message, typically an empty string in the provided example. ### Response Example ```json "" ``` ``` -------------------------------- ### Say Hello Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.DirectorySpringYapiApiExporterTest.txt This endpoint is a simple greeting service that says hello. It accepts a GET request. ```APIDOC ## GET /user/greeting ### Description A simple endpoint that returns a greeting. The markdown indicates that this endpoint does not update anything. ### Method GET ### Endpoint /user/greeting ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **res_body** (json) - The response body, expected to be a JSON schema string. #### Response Example ```json { "type": "string", "$schema": "http://json-schema.org/draft-04/schema#" } ``` ``` -------------------------------- ### Tag Match Example Source: https://github.com/tangcent/easy-yapi/blob/master/docs/knowledge-base/rule-guide.md Demonstrates the `#` prefix for matching elements tagged with a specific identifier. ```text #internal ``` -------------------------------- ### Say Hello Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.curl.CurlExporterTest.txt A simple endpoint to get a greeting. ```APIDOC ## Say Hello ### Description A simple endpoint to get a greeting. ### Method GET ### Endpoint /user/greeting ``` -------------------------------- ### User Page Query with POST Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.http.HttpClientFormatterTest.testParseRequests.txt This example shows a POST request with multipart/form-data for querying user data, similar to the ModelAttribute example. It's used when the server endpoint expects a PageRequest object with nested user details. ```http POST http://localhost:8080/test/call/page/user/post Content-Type: multipart/form-data token: Content-Type: multipart/form-data; boundary=WebAppBoundary --WebAppBoundary Content-Disposition: form-data; name="size" [size] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="user.id" [user.id] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="user.type" [user.type] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="user.name" [user.name] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="user.age" [user.age] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="user.sex" [user.sex] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="user.birthDay" [user.birthDay] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="user.regtime" [user.regtime] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="users[0].id" [users[0].id] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="users[0].type" [users[0].type] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="users[0].name" [users[0].name] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="users[0].age" [users[0].age] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="users[0].sex" [users[0].sex] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="users[0].birthDay" [users[0].birthDay] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="users[0].regtime" [users[0].regtime] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="t.id" [t.id] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="t.type" [t.type] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="t.name" [t.name] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="t.age" [t.age] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="t.sex" [t.sex] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="t.birthDay" [t.birthDay] --WebAppBoundary-- --WebAppBoundary Content-Disposition: form-data; name="t.regtime" [t.regtime] --WebAppBoundary-- ``` -------------------------------- ### Say Hello Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.http.HttpClientFormatterTest.testParseRequests.txt A simple GET request to greet the user without updating any data. ```http GET http://localhost:8080/user/greeting ``` -------------------------------- ### Test Query with Array Parameters Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.http.HttpClientFormatterTest.testParseRequests.txt Demonstrates passing array parameters in a GET request query string. ```http GET http://localhost:8080/test/arrays?string=&int=1&none=1 token: ``` -------------------------------- ### Annotation Match Example Source: https://github.com/tangcent/easy-yapi/blob/master/docs/knowledge-base/rule-guide.md Shows the `@` prefix for matching elements annotated with a specific annotation. ```text @org.springframework.web.bind.annotation.RestController ``` -------------------------------- ### Build the Project with Gradle Source: https://github.com/tangcent/easy-yapi/blob/master/CONTRIBUTING.md Use this command to build the project using Gradle. Ensure you have a compatible JDK and Kotlin version installed. ```bash ./gradlew build ``` -------------------------------- ### Postman API Exporter: Get User Info Endpoint Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.DirectorySpringPostmanApiExporterTest.txt Example of a Postman collection entry for a 'get user info' endpoint. It includes request details with a path parameter and a sample successful response with user data. ```json { "request": { "method": "GET", "description": "", "header": [ { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "url": { "path": [ "user", "get", ":id" ], "query": [ { "key": "id", "value": "", "equals": true, "description": "user id" } ], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/get/{id}" } }, "response": [ { "name": "get user info-Example", "originalRequest": { "method": "GET", "description": "", "header": [ { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "url": { "path": [ "user", "get", ":id" ], "query": [ { "key": "id", "value": "", "equals": true, "description": "user id" } ], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/get/{id}" } }, "code": 200, "_postman_previewlanguage": "json", "header": [ { "name": "date", "key": "date", "value": "Sun, 11 Apr 202106:56:34 GMT", "description": "The date and time that the message was sent" }, { "name": "server", "key": "server", "value": "Apache-Coyote/1.1", "description": "A name for the server" }, { "name": "transfer-encoding", "key": "transfer-encoding", "value": "chunked", "description": "The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity." }, { "name": "content-type", "key": "content-type", "value": "application/json;charset=UTF-8" } ], "body": "{ \"code\": 0, //response code \"msg\": \"success\", //message \"data\": { //response data \"id\": 0, //user id /** * user type * 1 :administration * 2 :a person, an animal or a plant * 3 :Anonymous visitor */ \"type\": 0, \"name\": \"Tony Stark\", //user name \"age\": 45, //user age \"sex\": 0, \"birthDay\": \"\", //user birthDay \"regtime\": \"" //user regtime } }" } ], "name": "get user info" } ``` -------------------------------- ### Postman Request Configuration Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequests.txt Defines a GET request to retrieve user information, including headers and URL parameters. It also shows example pre-request and test scripts. ```json { "request": { "method": "GET", "description": "", "header": [ { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "url": { "path": [ "user", "get", ":id" ], "query": [ { "key": "id", "value": "", "equals": true, "description": "user id" } ], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/get/{id}" } }, "response": [ { "name": "get user info-Example", "originalRequest": { "method": "GET", "description": "", "header": [ { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "url": { "path": [ "user", "get", ":id" ], "query": [ { "key": "id", "value": "", "equals": true, "description": "user id" } ], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/get/{id}" } }, "code": 200, "_postman_previewlanguage": "json", "header": [ { "name": "date", "key": "date", "value": "Sun, 11 Apr 202106:56:34 GMT", "description": "The date and time that the message was sent" }, { "name": "server", "key": "server", "value": "Apache-Coyote/1.1", "description": "A name for the server" }, { "name": "transfer-encoding", "key": "transfer-encoding", "value": "chunked", "description": "The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity." }, { "name": "content-type", "key": "content-type", "value": "application/json;charset=UTF-8" } ], "body": "{\n \"code\": 0,\n \"msg\": \"success\",\n \"data\": {\n \"id\": 0,\n \"type\": 0,\n \"name\": \"Tony Stark\",\n \"age\": 45,\n \"sex\": 0,\n \"birthDay\": \"\",\n \"regtime\": \"\"\n }\n}" } ], "name": "get user info", "event": [ { "listen": "prerequest", "script": { "exec": [ "pm.environment.set(\"token\", \"123456\");" ], "type": "text/javascript" } }, { "listen": "test", "script": { "exec": [ "pm.test(\"Successful POST request\", function () {", "pm.expect(pm.response.code).to.be.oneOf([201,202]);", "});" ], "type": "text/javascript" } } ] } ``` -------------------------------- ### List All Rule Files Source: https://github.com/tangcent/easy-yapi/blob/master/skills/easy-yapi-assistant/SKILL.md Lists all rule files that the plugin will load. Run from the project root. ```bash scripts/list_rule_files.sh ``` -------------------------------- ### Build and Run EasyYapi Plugin Source: https://github.com/tangcent/easy-yapi/blob/master/README.md Commands for building, running, and testing the EasyYapi plugin. Includes running an IDEA instance with the plugin and generating test coverage reports. ```bash # Run an IDEA instance with the plugin installed ./gradlew runIde # Run all tests ./gradlew clean test # Generate JaCoCo coverage report ./gradlew jacocoTestReport ``` -------------------------------- ### Get Controller Name Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.http.HttpClientFormatterTest.testParseRequests.txt Retrieves the controller name using a GET request. ```http GET http://localhost:8080/user/ctrl/name token: ``` -------------------------------- ### Get User Info Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.http.HttpClientFormatterTest.testParseRequests.txt Retrieves user information by ID using a GET request. ```http GET http://localhost:8080/user/get/{id}?id=0 token: ``` -------------------------------- ### Groovy Scripting Example Source: https://github.com/tangcent/easy-yapi/blob/master/docs/knowledge-base/rule-guide.md Illustrates the `groovy:` prefix for executing a Groovy script to determine a match. A truthy result indicates a match. ```text groovy: it.hasAnn("X") ``` -------------------------------- ### Get Existing Rules for Key Source: https://github.com/tangcent/easy-yapi/blob/master/skills/easy-yapi-assistant/SKILL.md Finds all configured values for a given key across project and global rule files. Prints the file and line content for each match. ```bash scripts/get_existing_rules_for_key.sh field.name ``` ```bash scripts/get_existing_rules_for_key.sh api.tag method.additional.header ``` -------------------------------- ### Get Test Controller Name Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.http.HttpClientFormatterTest.testParseRequests.txt Retrieves the test controller name using a GET request. ```http GET http://localhost:8080/test/ctrl/name token: ``` -------------------------------- ### Rule File Format Example Source: https://github.com/tangcent/easy-yapi/blob/master/skills/easy-yapi-assistant/docs/rule-guide.md Illustrates the basic structure of a rule file, including comments, key-value pairs, and optional filters. Rules are applied based on matching elements. ```properties # Comments start with # # Format: []= # filter — optional; goes INSIDE [...] AFTER the key # key — a rule key from the catalog below # value — literal text, expression, or script # A rule with no filter applies to every element: api.status=disabled # A rule with a filter applies only to matching elements: api.tag[$class:com.example.UserController]=user ``` -------------------------------- ### Bad Example: Unreadable Single-Line Filter Source: https://github.com/tangcent/easy-yapi/blob/master/skills/easy-yapi-assistant/SKILL.md Shows an example of an unreadable single-line filter for complex conditions, which should be refactored into a groovy value-block. ```properties method.additional.header[groovy: it.containingClass()?.name()?.startsWith("com.example.merchant.") && it.containingClass()?.name() != "com.example.merchant.AuthController"]={"name":"Authorization","value":"Bearer ${token}","desc":"JWT","required":true} ``` -------------------------------- ### Get User Info Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.SpringPostmanApiExporterTest.txt This endpoint retrieves user information based on a provided user ID. It supports GET requests to /user/get/{id}. ```APIDOC ## GET /user/get/{id} ### Description Retrieves detailed information about a specific user. ### Method GET ### Endpoint /user/get/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the user. #### Query Parameters - **id** (string) - Required - The unique identifier of the user. #### Request Body This endpoint does not accept a request body. ### Request Example ```json { "token": "" } ``` ### Response #### Success Response (200) - **code** (integer) - Response code - **msg** (string) - Message - **data** (object) - Response data - **id** (integer) - User ID - **type** (integer) - User type (1: administration, 2: person/animal/plant, 3: Anonymous visitor) - **name** (string) - User name - **age** (integer) - User age - **sex** (integer) - User sex - **birthDay** (string) - User birth date - **regtime** (string) - User registration time - **date** (string) - The date and time that the message was sent - **server** (string) - A name for the server - **transfer-encoding** (string) - The form of encoding used to safely transfer the entity to the user. - **content-type** (string) - application/json;charset=UTF-8 #### Response Example ```json { "code": 0, "msg": "success", "data": { "id": 0, "type": 0, "name": "Tony Stark", "age": 45, "sex": 0, "birthDay": "", "regtime": "" } } ``` ``` -------------------------------- ### GET Request for Custom Map Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.http.HttpClientFormatterTest.testParseRequestsToExistedDoc.txt A simple GET request to retrieve a custom map, passing a single key-value pair as a query parameter. ```http GET http://localhost:8080/test/return/customMap?key= token: ``` -------------------------------- ### Project Service Example in Kotlin Source: https://github.com/tangcent/easy-yapi/blob/master/AGENTS.md Demonstrates how to define a project-level service in Kotlin using IntelliJ's @Service annotation. This service is scoped to a specific IntelliJ project and provides a static getInstance method for easy access. ```kotlin import com.intellij.openapi.components.Service import com.intellij.openapi.project.Project import com.intellij.openapi.components.service @Service(Service.Level.PROJECT) class MyProjectService(private val project: Project) { companion object { fun getInstance(project: Project): MyProjectService = project.service() } } ``` -------------------------------- ### User Page Query with Array (GET) Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.curl.CurlFormatterTest.txt Performs a paginated query for users with array parameters via GET. Requires authentication token. ```APIDOC ## GET /test/call/page/user/array ### Description Performs a paginated query for users with array parameters. ### Method GET ### Endpoint /test/call/page/user/array ### Parameters #### Query Parameters - **id** (string) - Optional - User ID. - **type** (string) - Optional - User type. - **name** (string) - Optional - User name. - **age** (string) - Optional - User age. - **sex** (string) - Optional - User sex. - **birthDay** (string) - Optional - User birth date. - **regtime** (string) - Optional - User registration time. #### Headers - **token**: string - Required - Authentication token ``` -------------------------------- ### Exact Class Name Match Example Source: https://github.com/tangcent/easy-yapi/blob/master/docs/knowledge-base/rule-guide.md Demonstrates the `$class:` prefix for exact, fully-qualified class name matching. ```text $class:com.example.UserController ``` -------------------------------- ### Create User Request Example Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeCopyPostmanApiExporterTest.txt This snippet shows a POST request to create a user. It includes JSON headers and a raw JSON body with user details. ```json { "description": "", "header": [ { "key": "Content-Type", "value": "application/json", "type": "text", "description": "" }, { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "body": { "mode": "raw", "options": { "raw": { "language": "json" } }, "raw": "{\n \"id\": 0,\n \"type\": 0,\n \"name\": \"\",\n \"age\": 0,\n \"sex\": 0,\n \"birthDay\": \"\",\n \"regtime\": \"\"\n}" }, "url": { "path": [ "user", "add" ], "query": [], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/add" } } ``` -------------------------------- ### Rule File Format Examples Source: https://github.com/tangcent/easy-yapi/blob/master/src/main/resources/ai/agent-preamble.md Illustrates the basic key-value pair structure and the use of filters within square brackets for specific matching. The filter syntax is critical for precise rule application. ```properties api.tag[$class:com.example.UserController]=user method.additional.header={"name":"Authorization","value":"Bearer ${token}","desc":"","required":true} ``` -------------------------------- ### Create User Request Demo Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.SpringMarkdownApiExporterTest.txt Provides an example of the request body structure for creating a new user. Requires fields like ID, type, name, age, sex, birthday, and registration time. ```json { "id": 0, "type": 0, "name": "", "age": 0, "sex": 0, "birthDay": "", "regtime": "" } ``` -------------------------------- ### Groovy for Package/Pattern Matching Source: https://github.com/tangcent/easy-yapi/blob/master/docs/knowledge-base/rule-guide.md Explains how to use `groovy:` for package or pattern matching when `$class:` only supports exact matches. ```text groovy: it.containingClass()?.name()?.startsWith("com.example.web.") ``` -------------------------------- ### Get User Info Request Header Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection.txt Specifies the 'token' header for authentication in a GET request to retrieve user information. The token value is expected to be provided. ```json { "key": "token", "value": "", "type": "text", "description": "auth token" } ``` -------------------------------- ### Get User Control Name Request Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeUpdatePostmanApiExporterTest.txt This snippet defines a GET request to retrieve user control information by name. It includes a placeholder for the authentication token. ```json { "method": "GET", "description": "", "header": [ { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "url": { "path": [ "user", "ctrl", "name" ], "query": [], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/ctrl/name" } } ``` -------------------------------- ### Test Request Headers Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.curl.CurlFormatterTest.txt This command demonstrates sending custom headers, including 'x-token' and 'token'. ```bash curl -X GET -H 'x-token: ' -H 'token: ' http://localhost:8080/test/header ``` -------------------------------- ### Postman Request Body Example Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeUpdatePostmanApiExporterTest.txt Example of a JSON request body for retrieving user information, including response code, message, and user data fields. ```json { "code": 0, //response code "msg": "success", //message "data": { //response data "id": 0, //user id /** * user type * 1 :administration * 2 :a person, an animal or a plant * 3 :Anonymous visitor */ "type": 0, "name": "Tony Stark", //user name "age": 45, //user age "sex": 0, "birthDay": "", //user birthDay "regtime": "" //user regtime } } ``` -------------------------------- ### Pre-request Script Examples Source: https://github.com/tangcent/easy-yapi/blob/master/src/main/resources/docs/knowledge-base/easyapi-script-reference.md Set environment variables, add, or upsert headers before a request is sent. Uses Groovy syntax compatible with Postman's API. ```groovy // Set an environment variable pm.environment.set("timestamp", System.currentTimeMillis().toString()) // Add a header pm.request.headers.add("X-Request-Id", UUID.randomUUID().toString()) // Upsert a header (add or update) pm.request.headers.upsert("Authorization", "Bearer " + pm.environment.get("token")) ``` -------------------------------- ### Conventional Commit Message Example Source: https://github.com/tangcent/easy-yapi/blob/master/CONTRIBUTING.md This is an example of a commit message following the conventional commit format. It helps in standardizing commit history and automating changelog generation. ```text feat: add support for Kotlin sealed classes in type resolution ``` -------------------------------- ### Get User Controller Name Request Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection.txt This snippet defines a GET request to retrieve a user's controller name. It includes a placeholder for an authentication token in the header. ```json { "key": "token", "value": "", "type": "text", "description": "auth token" } ``` ```json { "path": [ "user", "ctrl", "name" ], "query": [], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/ctrl/name" } ``` -------------------------------- ### Test HttpServletResponse Query Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.curl.CurlFormatterTest.txt Demonstrates querying with HttpServletResponse parameters. ```bash curl -X GET -H 'token: ' http://localhost:8080/test/httpServletResponse ``` -------------------------------- ### GET Request for Nested Nodes Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.http.HttpClientFormatterTest.testParseRequestsToExistedDoc.txt This GET request demonstrates how to pass nested data structures as query parameters, including arrays and objects. The parameters are flattened with dot notation. ```http GET http://localhost:8080/test/return/root?id=&children[0].id=&children[0].code=&children[0].parent.key=&children[0].sub[0].key=&children[0].siblings[0].key= token: ``` -------------------------------- ### Test HttpServletRequest Query Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.curl.CurlFormatterTest.txt Demonstrates querying with HttpServletRequest parameters. ```bash curl -X GET -H 'token: ' http://localhost:8080/test/httpServletRequest ``` -------------------------------- ### GET User Info Request Structure Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsWithWrapCollection.txt Defines a GET request to retrieve user information, including headers and query parameters. This structure is typical for fetching specific user data. ```json { "request": { "method": "GET", "description": "", "header": [ { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "url": { "path": [ "user", "get", ":id" ], "query": [ { "key": "id", "value": "", "equals": true, "description": "user id" } ], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/get/{id}" } }, "response": [ { "name": "get user info-Example", "originalRequest": { "method": "GET", "description": "", "header": [ { "key": "token", "value": "", "type": "text", "description": "auth token" } ], "url": { "path": [ "user", "get", ":id" ], "query": [ { "key": "id", "value": "", "equals": true, "description": "user id" } ], "host": [ "{{test_default}}" ], "raw": "{{test_default}}/user/get/{id}" } }, "code": 200, "_postman_previewlanguage": "json", "header": [ { "name": "date", "key": "date", "value": "Sun, 11 Apr 202106:56:34 GMT", "description": "The date and time that the message was sent" }, { "name": "server", "key": "server", "value": "Apache-Coyote/1.1", "description": "A name for the server" }, { "name": "transfer-encoding", "key": "transfer-encoding", "value": "chunked", "description": "The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity." }, { "name": "content-type", "key": "content-type", "value": "application/json;charset=UTF-8" } ], "body": "{\n \"code\": 0, //response code\n \"msg\": \"success\", //message\n \"data\": { //response data\n \"id\": 0, //user id\n /**\n * user type\n * 1 :administration\n * 2 :a person, an animal or a plant\n * 3 :Anonymous visitor\n */\n \"type\": 0,\n \"name\": \"Tony Stark\", //user name\n \"age\": 45, //user age\n \"sex\": 0,\n \"birthDay\": \"\", //user birthDay\n \"regtime\": \"\" //user regtime\n }\n}" } ], "name": "get user info", "event": [ { "listen": "prerequest", "script": { "exec": [ "pm.environment.set(\"token\", \"123456\");" ], "type": "text/javascript" } }, { "listen": "test", "script": { "exec": [ "pm.test(\"Successful POST request\", function () {\n pm.expect(pm.response.code).to.be.oneOf([201,202]);\n});" ], "type": "text/javascript" } } ] } ``` -------------------------------- ### Object Helper/Utils Example in Kotlin Source: https://github.com/tangcent/easy-yapi/blob/master/AGENTS.md Illustrates the creation of a utility object in Kotlin for stateless helper functions. This pattern is used for pure computations that do not require instance-specific state. ```kotlin object MyHelperUtils { fun process(input: String): Result { /* pure computation */ } } ``` -------------------------------- ### Run Tests with Gradle Source: https://github.com/tangcent/easy-yapi/blob/master/CONTRIBUTING.md Execute this command to run all tests in the project using Gradle. This is crucial for ensuring code quality and stability. ```bash ./gradlew test ``` -------------------------------- ### Paginated User Query GET Request Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.http.HttpClientFormatterTest.testParseRequestsToExistedDoc.txt This GET request illustrates a paginated query for user data, including parameters for the page request itself and nested user objects within the request. ```http GET http://localhost:8080/test/call/page/user?size=&user.id=0&user.type=0&user.name=&user.age=0&user.sex=0&user.birthDay=&user.regtime=&users[0].id=0&users[0].type=0&users[0].name=&users[0].age=0&users[0].sex=0&users[0].birthDay=&users[0].regtime=&t.id=0&t.type=0&t.name=&t.age=0&t.sex=0&t.birthDay=&t.regtime= token: ``` -------------------------------- ### Postman Test Script Example Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsWithWrapCollection.txt JavaScript code snippet for a Postman test script. This example asserts that the response code is either 201 or 202, indicating a successful POST request. ```javascript pm.test("Successful POST request", function () { pm.expect(pm.response.code).to.be.oneOf([201,202]); }); ``` -------------------------------- ### Run the Plugin with Gradle Source: https://github.com/tangcent/easy-yapi/blob/master/CONTRIBUTING.md Use this command to run the IDE plugin during development. This allows for testing the plugin's functionality within an IDE environment. ```bash ./gradlew runIde ``` -------------------------------- ### List All Rule Files Source: https://github.com/tangcent/easy-yapi/blob/master/skills/easy-yapi-assistant/SKILL.md Use this script to list all rule files that the Easy YAPI plugin will load. This helps in understanding the scope of loaded rules. ```bash # List all rule files the plugin will load scripts/list_rule_files.sh ``` -------------------------------- ### Mark Fields as Required or Set Mock Values Source: https://github.com/tangcent/easy-yapi/blob/master/docs/knowledge-base/rule-guide.md Marks fields as required in documentation or provides mock values for examples. Useful for fields lacking explicit validation annotations or needing example data. ```groovy field.required[groovy: it.containingClass()?.name()?.startsWith("com.example.dto.")]=name,email ``` ```groovy field.mock[$class:com.example.dto.User]=groovy: it.name() == "age" ? 18 : null ``` -------------------------------- ### Test Query with Array Parameters Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.curl.CurlFormatterTest.txt Example of passing an array as a query parameter. Note the encoding of the empty string. ```bash curl -X GET -H 'token: ' http://localhost:8080/test/arrays?string=\&int=1\&none=1 ``` -------------------------------- ### Create User Source: https://github.com/tangcent/easy-yapi/blob/master/src/test/resources/result/com.itangcent.idea.plugin.api.export.curl.CurlExporterTest.txt Creates a new user with the provided details. ```APIDOC ## Create User ### Description Creates a new user with the provided details. ### Method POST ### Endpoint /user/add ### Parameters #### Request Body - **id** (integer) - Optional - The user's ID. - **type** (integer) - Optional - The user's type. - **name** (string) - Optional - The user's name. - **age** (integer) - Optional - The user's age. - **sex** (integer) - Optional - The user's sex. - **birthDay** (string) - Optional - The user's birth date. - **regtime** (string) - Optional - The user's registration time. ### Request Example { "id": 0, "type": 0, "name": "", "age": 0, "sex": 0, "birthDay": "", "regtime": "" } ```