diff --git a/gradle.properties b/gradle.properties index 77a8726ee..8853fef1f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ plugin_version=2.6.2.212.0 kotlin.code.style=official kotlin_version=1.8.0 junit_version=5.9.2 -itangcent_intellij_version=1.5.5 \ No newline at end of file +itangcent_intellij_version=1.5.52-SNAPSHOT \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/actions/FieldsToJson5Action.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/actions/FieldsToJson5Action.kt index 51e8035af..1ecce0bcb 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/actions/FieldsToJson5Action.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/actions/FieldsToJson5Action.kt @@ -21,7 +21,11 @@ class FieldsToJson5Action : FieldsToMessageAction("To Json5") { } override fun formatMessage(psiClass: PsiClass, type: PsiType?): String { - val obj = psiClassHelper!!.getTypeObject(type, psiClass, JsonOption.ALL) + val obj = psiClassHelper!!.getTypeObject( + psiType = type, + context = psiClass, + option = JsonOption.ALL + ) return ActionContext.getContext()!!.instance(Json5Formatter::class).format(obj) } } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/actions/FieldsToJsonAction.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/actions/FieldsToJsonAction.kt index 9c7478c5c..55b1c9b93 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/actions/FieldsToJsonAction.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/actions/FieldsToJsonAction.kt @@ -3,11 +3,10 @@ package com.itangcent.idea.plugin.actions import com.google.inject.Inject import com.intellij.psi.PsiClass import com.intellij.psi.PsiType -import com.itangcent.idea.plugin.format.MessageFormatter import com.itangcent.idea.plugin.format.SimpleJsonFormatter import com.itangcent.intellij.context.ActionContext -import com.itangcent.intellij.jvm.PsiClassHelper import com.itangcent.intellij.jvm.JsonOption +import com.itangcent.intellij.jvm.PsiClassHelper /** * @author tangcent @@ -22,7 +21,11 @@ class FieldsToJsonAction : FieldsToMessageAction("To Json") { } override fun formatMessage(psiClass: PsiClass, type: PsiType?): String { - val obj = psiClassHelper!!.getTypeObject(type, psiClass, JsonOption.READ_GETTER.or(JsonOption.READ_SETTER)) + val obj = psiClassHelper!!.getTypeObject( + psiType = type, + context = psiClass, + option = JsonOption.READ_GETTER or JsonOption.READ_SETTER + ) return ActionContext.getContext()!!.instance(SimpleJsonFormatter::class).format(obj) } } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/core/ClassExportRuleKeys.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/core/ClassExportRuleKeys.kt index 21d6d0597..3036a59c1 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/core/ClassExportRuleKeys.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/core/ClassExportRuleKeys.kt @@ -205,70 +205,6 @@ object ClassExportRuleKeys { StringRuleMode.SINGLE ) - /** - * The pre-request scripts in Postman to execute JavaScript before a request runs. - * - * @see [https://learning.postman.com/docs/writing-scripts/pre-request-scripts] - */ - val POST_PRE_REQUEST: RuleKey = SimpleRuleKey( - "postman.prerequest", - StringRuleMode.MERGE - ) - - /** - * Add pre-request scripts to entire collections as well as to folders within collections. - * This script will execute before every request in this collection or folder. - * - * @see [https://learning.postman.com/docs/writing-scripts/pre-request-scripts] - */ - val CLASS_POST_PRE_REQUEST: RuleKey = SimpleRuleKey( - "class.postman.prerequest", - StringRuleMode.MERGE - ) - - /** - * Add pre-request scripts to top collection. - * This script will execute before every request in this collection. - * - * @see [https://learning.postman.com/docs/writing-scripts/pre-request-scripts] - */ - val COLLECTION_POST_PRE_REQUEST: RuleKey = SimpleRuleKey( - "collection.postman.prerequest", - StringRuleMode.MERGE - ) - - /** - * The test scripts for Postman API requests in JavaScript. - * - * @see [https://learning.postman.com/docs/writing-scripts/test-scripts/] - */ - val POST_TEST: RuleKey = SimpleRuleKey( - "postman.test", - StringRuleMode.MERGE - ) - - /** - * Add test scripts to entire collections as well as to folders within collections. - * These tests will execute after every request in this collection. - * - * @see [https://learning.postman.com/docs/writing-scripts/test-scripts/] - */ - val CLASS_POST_TEST: RuleKey = SimpleRuleKey( - "class.postman.test", - StringRuleMode.MERGE - ) - - /** - * Add test scripts to top collection. - * These tests will execute after every request in this collection. - * - * @see [https://learning.postman.com/docs/writing-scripts/test-scripts/] - */ - val COLLECTION_POST_TEST: RuleKey = SimpleRuleKey( - "collection.postman.test", - StringRuleMode.MERGE - ) - val AFTER_EXPORT: RuleKey = SimpleRuleKey( "export.after", EventRuleMode.IGNORE_ERROR diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanApiExporter.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanApiExporter.kt index 5e5d26b48..4aaacc6d1 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanApiExporter.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanApiExporter.kt @@ -8,10 +8,14 @@ import com.itangcent.common.logger.traceError import com.itangcent.common.model.Request import com.itangcent.common.utils.* import com.itangcent.idea.plugin.api.ClassApiExporterHelper +import com.itangcent.idea.plugin.rule.SuvRuleContext +import com.itangcent.idea.plugin.rule.setDoc import com.itangcent.idea.plugin.settings.PostmanExportMode import com.itangcent.idea.plugin.settings.helper.PostmanSettingsHelper +import com.itangcent.idea.psi.resource import com.itangcent.idea.utils.FileSaveHelper import com.itangcent.idea.utils.ModuleHelper +import com.itangcent.intellij.config.rule.RuleComputer import com.itangcent.intellij.context.ActionContext import com.itangcent.intellij.logger.Logger @@ -38,16 +42,16 @@ class PostmanApiExporter { private lateinit var postmanFormatter: PostmanFormatter @Inject - private val moduleHelper: ModuleHelper? = null + private lateinit var moduleHelper: ModuleHelper @Inject - private val classApiExporterHelper: ClassApiExporterHelper? = null + private lateinit var classApiExporterHelper: ClassApiExporterHelper companion object : Log() fun export() { try { - val requests = classApiExporterHelper!!.export().mapNotNull { it as? Request } + val requests = classApiExporterHelper.export().mapNotNull { it as? Request } if (requests.isEmpty()) { logger.info("No api be found to export!") } else { @@ -105,6 +109,7 @@ class PostmanApiExporter { workspaceId: String?, ) { val postman = postmanFormatter.parseRequests(requests) + val createdCollection = postmanApiHelper.createCollection(postman, workspaceId) if (createdCollection.notNullOrEmpty()) { @@ -132,7 +137,7 @@ class PostmanApiExporter { private fun updateRequestsToPostman(requests: List) { val moduleGroupedMap = HashMap>() requests.forEach { - val module = moduleHelper!!.findModule(it.resource!!) ?: "easy-api" + val module = moduleHelper.findModule(it.resource!!) ?: "easy-api" moduleGroupedMap.safeComputeIfAbsent(module) { ArrayList() }!! .add(it) } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanExportRuleKeys.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanExportRuleKeys.kt new file mode 100644 index 000000000..3f1964fe4 --- /dev/null +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanExportRuleKeys.kt @@ -0,0 +1,78 @@ +package com.itangcent.idea.plugin.api.export.postman + +import com.itangcent.intellij.config.rule.EventRuleMode +import com.itangcent.intellij.config.rule.RuleKey +import com.itangcent.intellij.config.rule.SimpleRuleKey +import com.itangcent.intellij.config.rule.StringRuleMode + +object PostmanExportRuleKeys { + + /** + * The pre-request scripts in Postman to execute JavaScript before a request runs. + * + * @see [https://learning.postman.com/docs/writing-scripts/pre-request-scripts] + */ + val POST_PRE_REQUEST: RuleKey = SimpleRuleKey( + "postman.prerequest", + StringRuleMode.MERGE + ) + + /** + * Add pre-request scripts to entire collections as well as to folders within collections. + * This script will execute before every request in this collection or folder. + * + * @see [https://learning.postman.com/docs/writing-scripts/pre-request-scripts] + */ + val CLASS_POST_PRE_REQUEST: RuleKey = SimpleRuleKey( + "class.postman.prerequest", + StringRuleMode.MERGE + ) + + /** + * Add pre-request scripts to top collection. + * This script will execute before every request in this collection. + * + * @see [https://learning.postman.com/docs/writing-scripts/pre-request-scripts] + */ + val COLLECTION_POST_PRE_REQUEST: RuleKey = SimpleRuleKey( + "collection.postman.prerequest", + StringRuleMode.MERGE + ) + + /** + * The test scripts for Postman API requests in JavaScript. + * + * @see [https://learning.postman.com/docs/writing-scripts/test-scripts/] + */ + val POST_TEST: RuleKey = SimpleRuleKey( + "postman.test", + StringRuleMode.MERGE + ) + + /** + * Add test scripts to entire collections as well as to folders within collections. + * These tests will execute after every request in this collection. + * + * @see [https://learning.postman.com/docs/writing-scripts/test-scripts/] + */ + val CLASS_POST_TEST: RuleKey = SimpleRuleKey( + "class.postman.test", + StringRuleMode.MERGE + ) + + /** + * Add test scripts to top collection. + * These tests will execute after every request in this collection. + * + * @see [https://learning.postman.com/docs/writing-scripts/test-scripts/] + */ + val COLLECTION_POST_TEST: RuleKey = SimpleRuleKey( + "collection.postman.test", + StringRuleMode.MERGE + ) + + val AFTER_FORMAT: RuleKey = SimpleRuleKey( + "postman.format.after", + EventRuleMode.THROW_IN_ERROR + ) +} \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatFolderHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatFolderHelper.kt index 94797e329..457f58541 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatFolderHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatFolderHelper.kt @@ -4,7 +4,6 @@ import com.google.inject.Inject import com.google.inject.Singleton import com.intellij.psi.PsiClass import com.itangcent.common.utils.notNullOrBlank -import com.itangcent.idea.plugin.api.export.core.ClassExportRuleKeys import com.itangcent.idea.plugin.api.export.core.DefaultFormatFolderHelper import com.itangcent.idea.plugin.api.export.core.Folder import com.itangcent.intellij.config.rule.RuleComputer @@ -12,8 +11,8 @@ import com.itangcent.intellij.config.rule.computer import com.itangcent.intellij.jvm.element.ExplicitClass /** - * 1.support rule:[com.itangcent.idea.plugin.api.export.ClassExportRuleKeys.CLASS_POST_PRE_REQUEST] - * 2.support rule:[com.itangcent.idea.plugin.api.export.ClassExportRuleKeys.CLASS_POST_TEST] + * 1.support rule:[com.itangcent.idea.plugin.api.export.postman.PostmanExportRuleKeys.CLASS_POST_PRE_REQUEST] + * 2.support rule:[com.itangcent.idea.plugin.api.export.postman.PostmanExportRuleKeys.CLASS_POST_TEST] * * @see [https://learning.postman.com/docs/writing-scripts/intro-to-scripts/] */ @@ -26,14 +25,14 @@ class PostmanFormatFolderHelper : DefaultFormatFolderHelper() { override fun resolveFolderOfPsiClass(resource: PsiClass): Folder { val folder = super.resolveFolderOfPsiClass(resource) - val preRequest = ruleComputer!!.computer(ClassExportRuleKeys.CLASS_POST_PRE_REQUEST, resource) + val preRequest = ruleComputer!!.computer(PostmanExportRuleKeys.CLASS_POST_PRE_REQUEST, resource) if (preRequest.notNullOrBlank()) { - folder.setExt(ClassExportRuleKeys.POST_PRE_REQUEST.name(), preRequest) + folder.setExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name(), preRequest) } - val test = ruleComputer.computer(ClassExportRuleKeys.CLASS_POST_TEST, resource) + val test = ruleComputer.computer(PostmanExportRuleKeys.CLASS_POST_TEST, resource) if (test.notNullOrBlank()) { - folder.setExt(ClassExportRuleKeys.POST_TEST.name(), test) + folder.setExt(PostmanExportRuleKeys.POST_TEST.name(), test) } return folder @@ -42,14 +41,14 @@ class PostmanFormatFolderHelper : DefaultFormatFolderHelper() { override fun resolveFolderOfExplicitClass(resource: ExplicitClass): Folder { val folder = super.resolveFolderOfExplicitClass(resource) - val preRequest = ruleComputer!!.computer(ClassExportRuleKeys.CLASS_POST_PRE_REQUEST, resource) + val preRequest = ruleComputer!!.computer(PostmanExportRuleKeys.CLASS_POST_PRE_REQUEST, resource) if (preRequest.notNullOrBlank()) { - folder.setExt(ClassExportRuleKeys.POST_PRE_REQUEST.name(), preRequest) + folder.setExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name(), preRequest) } - val test = ruleComputer.computer(ClassExportRuleKeys.CLASS_POST_TEST, resource) + val test = ruleComputer.computer(PostmanExportRuleKeys.CLASS_POST_TEST, resource) if (test.notNullOrBlank()) { - folder.setExt(ClassExportRuleKeys.POST_TEST.name(), test) + folder.setExt(PostmanExportRuleKeys.POST_TEST.name(), test) } return folder diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatter.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatter.kt index c1f432670..df10f9847 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatter.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatter.kt @@ -16,8 +16,10 @@ import com.itangcent.idea.plugin.format.Json5Formatter import com.itangcent.idea.plugin.format.MessageFormatter import com.itangcent.idea.plugin.format.SimpleJsonFormatter import com.itangcent.idea.plugin.rule.SuvRuleContext +import com.itangcent.idea.plugin.rule.setDoc import com.itangcent.idea.plugin.settings.helper.PostmanSettingsHelper import com.itangcent.idea.psi.UltimateDocHelper +import com.itangcent.idea.psi.resource import com.itangcent.idea.psi.resourceClass import com.itangcent.idea.utils.ModuleHelper import com.itangcent.idea.utils.SystemProvider @@ -44,7 +46,7 @@ open class PostmanFormatter { private val formatFolderHelper: FormatFolderHelper? = null @Inject - private val ruleComputer: RuleComputer? = null + private lateinit var ruleComputer: RuleComputer @Inject private lateinit var postmanSettingsHelper: PostmanSettingsHelper @@ -62,20 +64,36 @@ open class PostmanFormatter { val url: HashMap = item.getAs("request", "url")!! val urls = urlSelector.selectUrls(request) + + val suvRuleContext = SuvRuleContext(request.resource()) + suvRuleContext.setDoc(request) + if (urls.single()) { - val path = urls.url() ?: "" + val selectedUrl = urls.url() + + val path = selectedUrl ?: "" url["path"] = parsePath(path) url["raw"] = RequestUtils.concatPath(url.getAs("host"), path) fixResponse(item) + + suvRuleContext.setExt("url", selectedUrl) + suvRuleContext.setExt("item", item) + ruleComputer.computer(PostmanExportRuleKeys.AFTER_FORMAT, suvRuleContext, request.resource()) + return listOf(item) } else { val host = item.getAs("request", "url", "host") ?: "" - return urls.urls().map { + return urls.urls().map { selectedUrl -> val copyItem = copyItem(item) val copyUrl: HashMap = copyItem.getAs("request", "url")!! - copyUrl["path"] = parsePath(it) - copyUrl["raw"] = RequestUtils.concatPath(host, it) + copyUrl["path"] = parsePath(selectedUrl) + copyUrl["raw"] = RequestUtils.concatPath(host, selectedUrl) fixResponse(copyItem) + + suvRuleContext.setExt("url", selectedUrl) + suvRuleContext.setExt("item", copyItem) + ruleComputer.computer(PostmanExportRuleKeys.AFTER_FORMAT, suvRuleContext, request.resource()) + return@map copyItem } } @@ -125,7 +143,7 @@ open class PostmanFormatter { var host = "{{host}}" val hostByRule = request.resourceClass() - ?.let { ruleComputer!!.computer(ClassExportRuleKeys.POST_MAN_HOST, it) } + ?.let { ruleComputer.computer(ClassExportRuleKeys.POST_MAN_HOST, it) } if (hostByRule == null) { val module = request.resource?.let { resource -> @@ -419,10 +437,14 @@ open class PostmanFormatter { } private fun parseScripts(extensible: Extensible, item: HashMap) { - if (extensible.hasAnyExt(ClassExportRuleKeys.POST_PRE_REQUEST.name(), ClassExportRuleKeys.POST_TEST.name())) { + if (extensible.hasAnyExt( + PostmanExportRuleKeys.POST_PRE_REQUEST.name(), + PostmanExportRuleKeys.POST_TEST.name() + ) + ) { addScriptsToItem(item, - { extensible.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name()) }, - { extensible.getExt(ClassExportRuleKeys.POST_TEST.name()) } + { extensible.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name()) }, + { extensible.getExt(PostmanExportRuleKeys.POST_TEST.name()) } ) } } @@ -472,31 +494,31 @@ open class PostmanFormatter { if (resource is Extensible) { addScriptsToItem(postman, { - ruleComputer!!.computer( - ClassExportRuleKeys.COLLECTION_POST_PRE_REQUEST, + ruleComputer.computer( + PostmanExportRuleKeys.COLLECTION_POST_PRE_REQUEST, context, null ) - .append(resource.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name()), "\n") + .append(resource.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name()), "\n") }, { - ruleComputer!!.computer( - ClassExportRuleKeys.COLLECTION_POST_TEST, + ruleComputer.computer( + PostmanExportRuleKeys.COLLECTION_POST_TEST, context, null ) - .append(resource.getExt(ClassExportRuleKeys.POST_TEST.name()), "\n") + .append(resource.getExt(PostmanExportRuleKeys.POST_TEST.name()), "\n") } ) } else { addScriptsToItem(postman, { - ruleComputer!!.computer( - ClassExportRuleKeys.COLLECTION_POST_PRE_REQUEST, + ruleComputer.computer( + PostmanExportRuleKeys.COLLECTION_POST_PRE_REQUEST, context, null ) }, { - ruleComputer!!.computer( - ClassExportRuleKeys.COLLECTION_POST_TEST, + ruleComputer.computer( + PostmanExportRuleKeys.COLLECTION_POST_TEST, context, null ) } @@ -754,22 +776,6 @@ open class PostmanFormatter { return rawUrl } - private fun parsePath(path: String): List { - val paths = path.trim().trim('/').split("/") - return paths.map { - if (it.contains('{')) { - val p = if (it.contains(':')) - it.substring(0, it.indexOf(':')) else - it - return@map p - .replace("{", ":") - .replace("}", "") - } else { - return@map it - } - } - } - private fun getBodyFormatter(type: Int): MessageFormatter { val useJson5 = postmanSettingsHelper.postmanJson5FormatType().needUseJson5(type) return if (useJson5) { @@ -783,6 +789,44 @@ open class PostmanFormatter { const val NULL_RESOURCE = "unknown" const val POSTMAN_SCHEMA_V2_1_0 = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + + /** + * Parses the given path string and returns a list of path segments. + * Placeholders enclosed in curly braces are replaced with ':' character. + * + * @param path The path string to parse. + * @return The list of parsed path segments. + */ + fun parsePath(path: String): List { + // Trim leading and trailing whitespace, and remove leading/trailing slashes + val paths = path.trim().trim('/').split("/") + + return paths.map { + return@map it.resolvePathVariable() + } + } + + /** + * Resolves a path segment by replacing placeholders enclosed in curly braces. + * + * @return The resolved path segment. + */ + private fun String.resolvePathVariable(): String { + // If the segment doesn't contain '{', it is not a placeholder + if (!contains('{')) { + return this + } + + // If the segment contains '{', it is a placeholder + val p = if (contains(':')) { + substring(0, indexOf(':')) // Extract the placeholder without additional information + } else { + this + } + + // Replace '{' with ':' and remove '}' + return p.replace("{", ":").replace("}", "") + } } } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanRequestBuilderListener.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanRequestBuilderListener.kt index 16499b3fb..4d5e9e28d 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanRequestBuilderListener.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanRequestBuilderListener.kt @@ -4,7 +4,6 @@ import com.google.inject.Inject import com.itangcent.common.model.* import com.itangcent.common.utils.notNullOrBlank import com.itangcent.idea.plugin.api.export.condition.ConditionOnChannel -import com.itangcent.idea.plugin.api.export.core.ClassExportRuleKeys import com.itangcent.idea.plugin.api.export.core.ExportContext import com.itangcent.idea.plugin.api.export.core.MethodExportContext import com.itangcent.idea.plugin.api.export.core.RequestBuilderListener @@ -12,8 +11,8 @@ import com.itangcent.intellij.config.rule.RuleComputer import com.itangcent.intellij.config.rule.computer /** - * 1.support rule:[com.itangcent.idea.plugin.api.export.core.ClassExportRuleKeys.POST_PRE_REQUEST] - * 2.support rule:[com.itangcent.idea.plugin.api.export.core.ClassExportRuleKeys.POST_TEST] + * 1.support rule:[com.itangcent.idea.plugin.api.export.postman.PostmanExportRuleKeys.POST_PRE_REQUEST] + * 2.support rule:[com.itangcent.idea.plugin.api.export.postman.PostmanExportRuleKeys.POST_TEST] * * @see [https://learning.postman.com/docs/writing-scripts/intro-to-scripts/] */ @@ -100,14 +99,14 @@ class PostmanRequestBuilderListener : RequestBuilderListener { } override fun processCompleted(methodExportContext: MethodExportContext, request: Request) { - val preRequest = ruleComputer.computer(ClassExportRuleKeys.POST_PRE_REQUEST, methodExportContext.element()) + val preRequest = ruleComputer.computer(PostmanExportRuleKeys.POST_PRE_REQUEST, methodExportContext.element()) if (preRequest.notNullOrBlank()) { - request.setExt(ClassExportRuleKeys.POST_PRE_REQUEST.name(), preRequest) + request.setExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name(), preRequest) } - val test = ruleComputer.computer(ClassExportRuleKeys.POST_TEST, methodExportContext.element()) + val test = ruleComputer.computer(PostmanExportRuleKeys.POST_TEST, methodExportContext.element()) if (test.notNullOrBlank()) { - request.setExt(ClassExportRuleKeys.POST_TEST.name(), test) + request.setExt(PostmanExportRuleKeys.POST_TEST.name(), test) } } } \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiClassExportRuleKeys.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiClassExportRuleKeys.kt index b02041e4b..14d08e5ea 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiClassExportRuleKeys.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiClassExportRuleKeys.kt @@ -48,4 +48,9 @@ object YapiClassExportRuleKeys { "api.open", BooleanRuleMode.ANY ) + + val AFTER_FORMAT: RuleKey = SimpleRuleKey( + "yapi.format.after", + EventRuleMode.THROW_IN_ERROR + ) } \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiFormatter.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiFormatter.kt index 503142f36..0c4dee087 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiFormatter.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiFormatter.kt @@ -12,6 +12,8 @@ import com.itangcent.idea.plugin.api.export.UrlSelector import com.itangcent.idea.plugin.api.export.core.ClassExportRuleKeys import com.itangcent.idea.plugin.format.Json5Formatter import com.itangcent.idea.plugin.render.MarkdownRender +import com.itangcent.idea.plugin.rule.SuvRuleContext +import com.itangcent.idea.plugin.rule.setDoc import com.itangcent.idea.plugin.settings.helper.YapiSettingsHelper import com.itangcent.idea.psi.resource import com.itangcent.idea.psi.resourceMethod @@ -38,19 +40,19 @@ open class YapiFormatter { private lateinit var logger: Logger @Inject - private val ruleComputer: RuleComputer? = null + private lateinit var ruleComputer: RuleComputer @Inject - private val configReader: ConfigReader? = null + private lateinit var configReader: ConfigReader @Inject private lateinit var actionContext: ActionContext @Inject - protected val docHelper: DocHelper? = null + protected lateinit var docHelper: DocHelper @Inject - protected val markdownRender: MarkdownRender? = null + protected lateinit var markdownRender: MarkdownRender @Inject protected lateinit var systemProvider: SystemProvider @@ -180,7 +182,7 @@ open class YapiFormatter { } private fun getPathOfMethodDoc(methodDoc: MethodDoc): String { - val path = ruleComputer!!.computer(ClassExportRuleKeys.METHOD_DOC_PATH, methodDoc.resource()!!) + val path = ruleComputer.computer(ClassExportRuleKeys.METHOD_DOC_PATH, methodDoc.resource()!!) if (path.notNullOrEmpty()) { return path!! @@ -190,7 +192,7 @@ open class YapiFormatter { } private fun getHttpMethodOfMethodDoc(methodDoc: MethodDoc): String { - return ruleComputer!!.computer(ClassExportRuleKeys.METHOD_DOC_METHOD, methodDoc.resource()!!) + return ruleComputer.computer(ClassExportRuleKeys.METHOD_DOC_METHOD, methodDoc.resource()!!) ?: "POST" } @@ -233,19 +235,33 @@ open class YapiFormatter { val item = request2Item(request) val urls = urlSelector.selectUrls(request) + + val suvRuleContext = SuvRuleContext(request.resource()) + suvRuleContext.setDoc(request) + if (urls.single()) { - val path = formatPath(urls.url() ?: "") + val selectedUrl = urls.url() ?: "" + val path = formatPath(selectedUrl) val queryPath: HashMap = item.getAs("query_path")!! queryPath["path"] = path item["path"] = path + + suvRuleContext.setExt("url", selectedUrl) + suvRuleContext.setExt("item", item) + ruleComputer.computer(YapiClassExportRuleKeys.AFTER_FORMAT, suvRuleContext, request.resource()) + return listOf(item) } else { - return urls.urls().map { + return urls.urls().map { selectedUrl -> val copyItem = copyItem(item) - val path = formatPath(it) + val path = formatPath(selectedUrl) val queryPath: HashMap = copyItem.getAs("query_path")!! copyItem["path"] = path queryPath["path"] = path + + suvRuleContext.setExt("url", selectedUrl) + suvRuleContext.setExt("item", copyItem) + ruleComputer.computer(YapiClassExportRuleKeys.AFTER_FORMAT, suvRuleContext, request.resource()) return@map copyItem } } @@ -474,7 +490,7 @@ open class YapiFormatter { } protected fun findReturnOfMethod(method: PsiMethod): String? { - return docHelper!!.findDocByTag(method, "return") + return docHelper.findDocByTag(method, "return") } private fun jsonTypeOf(typedObject: Any?): String { @@ -851,10 +867,10 @@ open class YapiFormatter { val existedDesc = item["markdown"] if (existedDesc == null) { item["markdown"] = desc - item["desc"] = markdownRender?.render(desc) ?: "

$desc

" + item["desc"] = markdownRender.render(desc) ?: "

$desc

" } else { item["markdown"] = "$existedDesc\n$desc" - item["desc"] = markdownRender?.render(desc) ?: "

$existedDesc\n$desc

" + item["desc"] = markdownRender.render(desc) ?: "

$existedDesc\n$desc

" } } @@ -866,7 +882,7 @@ open class YapiFormatter { private fun readMockRules(): List { val mockRules = arrayListOf() - configReader!!.foreach({ key -> + configReader.foreach({ key -> key.startsWith("mock.") }, { key, value -> try { @@ -938,7 +954,7 @@ open class YapiFormatter { //endregion mock rules--------------------------------------------------------- protected fun autoFormatUrl(): Boolean { - return configReader!!.first("auto.format.url")?.toBool() ?: true + return configReader.first("auto.format.url")?.toBool() ?: true } companion object { diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/EnumProcessInitializer.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/EnumProcessInitializer.kt index 9ae60acba..7202e24d5 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/EnumProcessInitializer.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/EnumProcessInitializer.kt @@ -9,31 +9,33 @@ import com.itangcent.idea.swing.MessagesHelper import com.itangcent.idea.swing.showChooseWithTipDialog import com.itangcent.intellij.context.ActionContext import com.itangcent.intellij.logger.Logger -import java.util.concurrent.TimeUnit class EnumProcessInitializer : Initializer { override fun init() { val actionContext = ActionContext.getContext() ?: return - try { - val propertiesComponent = PropertiesComponent.getInstance() - if (EventRecords.getRecord(EventRecords.ENUM_RESOLVE) > 0 && !propertiesComponent.getBoolean( - ENUM_RECOMMEND_ITEMS_CONFIRMED_KEY) - ) { - val selectedRecommendItem = actionContext.instance(MessagesHelper::class).showChooseWithTipDialog( - ENUM_RECOMMEND_ITEMS_MESSAGE, - ENUM_RECOMMEND_ITEMS, - { it.first }, { it.second }) - if (selectedRecommendItem != null) { - val recommendConfigSettingsHelper = actionContext.instance(RecommendConfigSettingsHelper::class) - recommendConfigSettingsHelper.removeConfig(*ENUM_RECOMMEND_ITEMS - .filter { it != selectedRecommendItem } - .mapToTypedArray { it.first }) - recommendConfigSettingsHelper.addConfig(selectedRecommendItem.first) + actionContext.runAsync { + try { + val propertiesComponent = PropertiesComponent.getInstance() + if (EventRecords.getRecord(EventRecords.ENUM_RESOLVE) > 0 && !propertiesComponent.getBoolean( + ENUM_RECOMMEND_ITEMS_CONFIRMED_KEY + ) + ) { + val selectedRecommendItem = actionContext.instance(MessagesHelper::class).showChooseWithTipDialog( + ENUM_RECOMMEND_ITEMS_MESSAGE, + ENUM_RECOMMEND_ITEMS, + { it.first }, { it.second }) + if (selectedRecommendItem != null) { + val recommendConfigSettingsHelper = actionContext.instance(RecommendConfigSettingsHelper::class) + recommendConfigSettingsHelper.removeConfig(*ENUM_RECOMMEND_ITEMS + .filter { it != selectedRecommendItem } + .mapToTypedArray { it.first }) + recommendConfigSettingsHelper.addConfig(selectedRecommendItem.first) + } + propertiesComponent.setValue(ENUM_RECOMMEND_ITEMS_CONFIRMED_KEY, true) } - propertiesComponent.setValue(ENUM_RECOMMEND_ITEMS_CONFIRMED_KEY, true) + } catch (e: Exception) { + actionContext.instance(Logger::class).traceError("error in enumRecommendItemsConfirmed.", e) } - } catch (e: Exception) { - actionContext.instance(Logger::class).traceError("error in enumRecommendItemsConfirmed.", e) } } diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatFolderHelperTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatFolderHelperTest.kt index d52f6ae90..f73e4d599 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatFolderHelperTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatFolderHelperTest.kt @@ -15,8 +15,8 @@ import org.junit.jupiter.api.condition.OS /** * Test case of [PostmanFormatFolderHelper] - * Test case of rule: [com.itangcent.idea.plugin.api.export.ClassExportRuleKeys.CLASS_POST_PRE_REQUEST] - * Test case of rule: [com.itangcent.idea.plugin.api.export.ClassExportRuleKeys.CLASS_POST_TEST] + * Test case of rule: [com.itangcent.idea.plugin.api.export.postman.PostmanExportRuleKeys.CLASS_POST_PRE_REQUEST] + * Test case of rule: [com.itangcent.idea.plugin.api.export.postman.PostmanExportRuleKeys.CLASS_POST_TEST] */ internal class PostmanFormatFolderHelperTest : PluginContextLightCodeInsightFixtureTestCase() { @@ -55,23 +55,23 @@ internal class PostmanFormatFolderHelperTest : PluginContextLightCodeInsightFixt formatFolderHelper.resolveFolder(userCtrlPsiClass).let { assertEquals(Folder("apis about user", "apis about user\n" + "access user info"), it) - assertEquals("pm.environment.set(\"token\", \"123456\");", it.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name())) + assertEquals("pm.environment.set(\"token\", \"123456\");", it.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name())) assertEquals("pm.test(\"Successful POST request\", function () {\n" + "pm.expect(pm.response.code).to.be.oneOf([201,202]);\n" + - "});", it.getExt(ClassExportRuleKeys.POST_TEST.name())) + "});", it.getExt(PostmanExportRuleKeys.POST_TEST.name())) } formatFolderHelper.resolveFolder(userCtrlPsiClass.methods[0]).let { assertEquals(Folder("apis about user", "apis about user\n" + "access user info"), it) - assertEquals("pm.environment.set(\"token\", \"123456\");", it.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name())) + assertEquals("pm.environment.set(\"token\", \"123456\");", it.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name())) assertEquals("pm.test(\"Successful POST request\", function () {\n" + "pm.expect(pm.response.code).to.be.oneOf([201,202]);\n" + - "});", it.getExt(ClassExportRuleKeys.POST_TEST.name())) + "});", it.getExt(PostmanExportRuleKeys.POST_TEST.name())) } formatFolderHelper.resolveFolder(userCtrlPsiClass.methods[1]).let { assertEquals(Folder("update-apis", ""), it) - assertNull(it.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name())) - assertNull(it.getExt(ClassExportRuleKeys.POST_TEST.name())) + assertNull(it.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name())) + assertNull(it.getExt(PostmanExportRuleKeys.POST_TEST.name())) } //test for ExplicitClass & ExplicitMethod @@ -79,46 +79,46 @@ internal class PostmanFormatFolderHelperTest : PluginContextLightCodeInsightFixt formatFolderHelper.resolveFolder(explicitClass).let { assertEquals(Folder("apis about user", "apis about user\n" + "access user info"), it) - assertEquals("pm.environment.set(\"token\", \"123456\");", it.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name())) + assertEquals("pm.environment.set(\"token\", \"123456\");", it.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name())) assertEquals("pm.test(\"Successful POST request\", function () {\n" + "pm.expect(pm.response.code).to.be.oneOf([201,202]);\n" + - "});", it.getExt(ClassExportRuleKeys.POST_TEST.name())) + "});", it.getExt(PostmanExportRuleKeys.POST_TEST.name())) } formatFolderHelper.resolveFolder(explicitClass.methods()[0]).let { assertEquals(Folder("apis about user", "apis about user\n" + "access user info"), it) - assertEquals("pm.environment.set(\"token\", \"123456\");", it.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name())) + assertEquals("pm.environment.set(\"token\", \"123456\");", it.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name())) assertEquals("pm.test(\"Successful POST request\", function () {\n" + "pm.expect(pm.response.code).to.be.oneOf([201,202]);\n" + - "});", it.getExt(ClassExportRuleKeys.POST_TEST.name())) + "});", it.getExt(PostmanExportRuleKeys.POST_TEST.name())) } formatFolderHelper.resolveFolder(explicitClass.methods()[1]).let { assertEquals(Folder("update-apis", ""), it) - assertNull(it.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name())) - assertNull(it.getExt(ClassExportRuleKeys.POST_TEST.name())) + assertNull(it.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name())) + assertNull(it.getExt(PostmanExportRuleKeys.POST_TEST.name())) } //test for PsiClassResource & PsiMethodResource formatFolderHelper.resolveFolder(PsiClassResource(userCtrlPsiClass)).let { assertEquals(Folder("apis about user", "apis about user\n" + "access user info"), it) - assertEquals("pm.environment.set(\"token\", \"123456\");", it.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name())) + assertEquals("pm.environment.set(\"token\", \"123456\");", it.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name())) assertEquals("pm.test(\"Successful POST request\", function () {\n" + "pm.expect(pm.response.code).to.be.oneOf([201,202]);\n" + - "});", it.getExt(ClassExportRuleKeys.POST_TEST.name())) + "});", it.getExt(PostmanExportRuleKeys.POST_TEST.name())) } formatFolderHelper.resolveFolder(PsiMethodResource(userCtrlPsiClass.methods[0], userCtrlPsiClass)).let { assertEquals(Folder("apis about user", "apis about user\n" + "access user info"), it) - assertEquals("pm.environment.set(\"token\", \"123456\");", it.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name())) + assertEquals("pm.environment.set(\"token\", \"123456\");", it.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name())) assertEquals("pm.test(\"Successful POST request\", function () {\n" + "pm.expect(pm.response.code).to.be.oneOf([201,202]);\n" + - "});", it.getExt(ClassExportRuleKeys.POST_TEST.name())) + "});", it.getExt(PostmanExportRuleKeys.POST_TEST.name())) } formatFolderHelper.resolveFolder(PsiMethodResource(userCtrlPsiClass.methods[1], userCtrlPsiClass)).let { assertEquals(Folder("update-apis", ""), it) - assertNull(it.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name())) - assertNull(it.getExt(ClassExportRuleKeys.POST_TEST.name())) + assertNull(it.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name())) + assertNull(it.getExt(PostmanExportRuleKeys.POST_TEST.name())) } } diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatterTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatterTest.kt index 5964f4383..04ef29b9c 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatterTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatterTest.kt @@ -53,10 +53,6 @@ internal class PostmanFormatterTest : PostmanSpringClassExporterBaseTest() { builder.mock(DataContext::class) } - override fun afterBind() { - super.afterBind() - } - override fun shouldRunTest(): Boolean { return !OS.WINDOWS.isCurrentOs } @@ -253,4 +249,18 @@ internal class PostmanFormatterTest : PostmanSpringClassExporterBaseTest() { GsonUtils.prettyJson(collectionInfo) ) } + + fun testParsePath() { + // Test case input + val path = "/users/{userId}/orders/{orderId:int}/details" + + // Expected output + val expectedSegments = listOf("users", ":userId", "orders", ":orderId", "details") + + // Call the function + val actualSegments = PostmanFormatter.parsePath(path) + + // Assert the result + assertEquals(expectedSegments, actualSegments) + } } \ No newline at end of file diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanSpringClassExporterBaseTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanSpringClassExporterBaseTest.kt index db86b4e2e..3cf2dba05 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanSpringClassExporterBaseTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanSpringClassExporterBaseTest.kt @@ -57,24 +57,33 @@ internal abstract class PostmanSpringClassExporterBaseTest : PluginContextLightC } override fun customConfig(): String { - return "method.additional.header[!@com.itangcent.annotation.Public]={name: \"token\",value: \"\",desc: \"auth token\",required:true, demo:\"123456\"}\n" + - "#[converts]*\n" + - "#The ObjectId and Date will be parsed as strings\n" + - "json.rule.convert[org.bson.types.ObjectId]=java.lang.String\n" + - "json.rule.convert[java.util.Date]=java.lang.String\n" + - "json.rule.convert[java.sql.Timestamp]=java.lang.String\n" + - "json.rule.convert[java.time.LocalDateTime]=java.lang.String\n" + - "json.rule.convert[java.time.LocalDate]=java.lang.String\n" + - "# read folder name from tag `folder`\n" + - "folder.name=#folder\n" + - "postman.prerequest=```\n" + - "pm.environment.set(\"token\", \"123456\");\n" + - "```\n" + - "postman.test=```\n" + - "pm.test(\"Successful POST request\", function () {\n" + - "pm.expect(pm.response.code).to.be.oneOf([201,202]);\n" + - "});\n" + - "```" + return """ + method.additional.header[!@com.itangcent.annotation.Public]={name: "token",value: "",desc: "auth token",required:true, demo:"123456"} + #[converts]* + #The ObjectId and Date will be parsed as strings + json.rule.convert[org.bson.types.ObjectId]=java.lang.String + json.rule.convert[java.util.Date]=java.lang.String + json.rule.convert[java.sql.Timestamp]=java.lang.String + json.rule.convert[java.time.LocalDateTime]=java.lang.String + json.rule.convert[java.time.LocalDate]=java.lang.String + # read folder name from tag `folder` + folder.name=#folder + postman.prerequest=``` + pm.environment.set("token", "123456"); + ``` + postman.test=``` + pm.test("Successful POST request", function () { + pm.expect(pm.response.code).to.be.oneOf([201,202]); + }); + ``` + path.multi=all + postman.format.after=groovy:``` + if(url.contains("/admin")){ + item["name"] = "[admin]"+item["name"] + item["request"]["description"] = "[admin]"+item["request"]["description"] + } + ``` + """ } override fun bind(builder: ActionContext.ActionContextBuilder) { diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanSpringRequestClassExporterTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanSpringRequestClassExporterTest.kt index 3743117cd..34ca4814d 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanSpringRequestClassExporterTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanSpringRequestClassExporterTest.kt @@ -3,7 +3,6 @@ package com.itangcent.idea.plugin.api.export.postman import com.itangcent.common.kit.toJson import com.itangcent.common.model.Request import com.itangcent.debug.LoggerCollector -import com.itangcent.idea.plugin.api.export.core.ClassExportRuleKeys import com.itangcent.idea.plugin.api.export.core.requestOnly import com.itangcent.idea.psi.PsiResource import com.itangcent.intellij.context.ActionContext @@ -16,8 +15,8 @@ import org.junit.jupiter.api.condition.OS /** * Test case of export spring apis with [PostmanRequestBuilderListener] - * 1.support rule:[com.itangcent.idea.plugin.api.export.core.ClassExportRuleKeys.POST_PRE_REQUEST] - * 2.support rule:[com.itangcent.idea.plugin.api.export.core.ClassExportRuleKeys.POST_TEST] + * 1.support rule:[com.itangcent.idea.plugin.api.export.postman.PostmanExportRuleKeys.POST_PRE_REQUEST] + * 2.support rule:[com.itangcent.idea.plugin.api.export.postman.PostmanExportRuleKeys.POST_TEST] * */ internal class PostmanSpringRequestClassExporterTest : PostmanSpringClassExporterBaseTest() { @@ -55,12 +54,12 @@ internal class PostmanSpringRequestClassExporterTest : PostmanSpringClassExporte assertEquals( "pm.environment.set(\"token\", \"123456\");", - request.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name()) + request.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name()) ) assertEquals( "pm.test(\"Successful POST request\", function () {\n" + "pm.expect(pm.response.code).to.be.oneOf([201,202]);\n" + - "});", request.getExt(ClassExportRuleKeys.POST_TEST.name()) + "});", request.getExt(PostmanExportRuleKeys.POST_TEST.name()) ) assertNull(request.body) assertEquals("", request.response!!.first().body.toJson()) @@ -73,12 +72,12 @@ internal class PostmanSpringRequestClassExporterTest : PostmanSpringClassExporte assertEquals( "pm.environment.set(\"token\", \"123456\");", - request.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name()) + request.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name()) ) assertEquals( "pm.test(\"Successful POST request\", function () {\n" + "pm.expect(pm.response.code).to.be.oneOf([201,202]);\n" + - "});", request.getExt(ClassExportRuleKeys.POST_TEST.name()) + "});", request.getExt(PostmanExportRuleKeys.POST_TEST.name()) ) assertNull(request.body) assertEquals("", request.response!!.first().body.toJson()) @@ -91,12 +90,12 @@ internal class PostmanSpringRequestClassExporterTest : PostmanSpringClassExporte assertEquals( "pm.environment.set(\"token\", \"123456\");", - request.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name()) + request.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name()) ) assertEquals( "pm.test(\"Successful POST request\", function () {\n" + "pm.expect(pm.response.code).to.be.oneOf([201,202]);\n" + - "});", request.getExt(ClassExportRuleKeys.POST_TEST.name()) + "});", request.getExt(PostmanExportRuleKeys.POST_TEST.name()) ) assertNull(request.body.toJson()) assertEquals( @@ -112,12 +111,12 @@ internal class PostmanSpringRequestClassExporterTest : PostmanSpringClassExporte assertEquals( "pm.environment.set(\"token\", \"123456\");", - request.getExt(ClassExportRuleKeys.POST_PRE_REQUEST.name()) + request.getExt(PostmanExportRuleKeys.POST_PRE_REQUEST.name()) ) assertEquals( "pm.test(\"Successful POST request\", function () {\n" + "pm.expect(pm.response.code).to.be.oneOf([201,202]);\n" + - "});", request.getExt(ClassExportRuleKeys.POST_TEST.name()) + "});", request.getExt(PostmanExportRuleKeys.POST_TEST.name()) ) assertEquals( "{\"id\":0,\"@comment\":{\"id\":\"user id\",\"type\":\"user type\",\"type@options\":[{\"value\":1,\"desc\":\"administration\"},{\"value\":2,\"desc\":\"a person, an animal or a plant\"},{\"value\":3,\"desc\":\"Anonymous visitor\"}],\"name\":\"user name\",\"age\":\"user age\",\"sex\":\"\",\"birthDay\":\"user birthDay\",\"regtime\":\"user regtime\"},\"type\":0,\"name\":\"\",\"age\":0,\"sex\":0,\"birthDay\":\"\",\"regtime\":\"\"}", diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/spring/DefaultSpringRequestMappingResolverTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/spring/DefaultSpringRequestMappingResolverTest.kt index 6cc34bab6..5b8a16171 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/spring/DefaultSpringRequestMappingResolverTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/spring/DefaultSpringRequestMappingResolverTest.kt @@ -66,7 +66,7 @@ internal class DefaultSpringRequestMappingResolverTest : PluginContextLightCodeI springRequestMappingResolver.resolveRequestMapping(userCtrlPsiClass.methods[1]).toJson() ) assertEquals( - "{\"method\":\"POST\",\"value\":\"/add\"}", + "{\"method\":\"POST\",\"value\":[\"/add\",\"/admin/add\"]}", springRequestMappingResolver.resolveRequestMapping(userCtrlPsiClass.methods[2]).toJson() ) assertEquals( diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/spring/StandardSpringRequestMappingResolverTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/spring/StandardSpringRequestMappingResolverTest.kt index eb20fb22d..ee784d96d 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/spring/StandardSpringRequestMappingResolverTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/spring/StandardSpringRequestMappingResolverTest.kt @@ -63,7 +63,7 @@ internal class StandardSpringRequestMappingResolverTest : PluginContextLightCode standardSpringRequestMappingResolver.resolveRequestMapping(userCtrlPsiClass.methods[1]).toJson() ) assertEquals( - "{\"method\":\"POST\",\"value\":\"/add\"}", + "{\"method\":\"POST\",\"value\":[\"/add\",\"/admin/add\"]}", standardSpringRequestMappingResolver.resolveRequestMapping(userCtrlPsiClass.methods[2]).toJson() ) assertEquals( diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiFormatterTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiFormatterTest.kt index d58859b55..5b0e9abbe 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiFormatterTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiFormatterTest.kt @@ -41,16 +41,17 @@ internal abstract class YapiFormatterTest : YapiSpringClassExporterBaseTest() { override fun customConfig(): String { - return super.customConfig() + "\n" + - "mock.[code|integer]=200\n" + - "mock.[msg|string]=ok\n" + - "mock.[*.name|string]=tangcent\n" + - "mock.[*.age|integer]=18\n" + - "mock.[*.sex|integer]=1\n" + - "mock.[*.*birth*|string]=@date\n" + - "mock.[*.*time*|string]=@datetime\n" + - "mock.[*|integer]=666\n" + - "mock.[*|string]=str\n" + return """${super.customConfig()} + mock.[code|integer]=200 + mock.[msg|string]=ok + mock.[*.name|string]=tangcent + mock.[*.age|integer]=18 + mock.[*.sex|integer]=1 + mock.[*.*birth*|string]=@date + mock.[*.*time*|string]=@datetime + mock.[*|integer]=666 + mock.[*|string]=str + """ } override fun shouldRunTest(): Boolean { @@ -85,6 +86,10 @@ internal abstract class YapiFormatterTest : YapiSpringClassExporterBaseTest() { "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"200\\\"},\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"ok\\\"},\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/get/{id}\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"get user info\",\"path\":\"/user/get/{id}\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[\"deprecated\"],\"req_query\":[{\"name\":\"id\",\"value\":0,\"desc\":\"user id\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"undone\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[2]).toJson() ) + assertEquals( + "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"200\\\"},\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"ok\\\"},\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/admin/add\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"type\":\"static\",\"title\":\"create an user\",\"req_body_form\":[],\"req_body_is_json_schema\":true,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\",\"queryPath\":{\"params\":[]},\"path\":\"/user/add\"},{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"200\\\"},\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"ok\\\"},\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/admin/add\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"type\":\"static\",\"title\":\"[admin]create an user\",\"req_body_form\":[],\"req_body_is_json_schema\":true,\"__v\":0,\"markdown\":\"[admin]\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"[admin]

\",\"queryPath\":{\"params\":[],\"path\":\"/user/add\"},\"path\":\"/user/admin/add\"}]", + yapiFormatter.doc2Items(requests[3]).toJson() + ) val apiCntInUserCtrl = userCtrlPsiClass.methods.size assertEquals( "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/ctrl/name\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"current ctrl name\",\"path\":\"/default/ctrl/name\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\"}]", @@ -132,6 +137,10 @@ internal abstract class YapiFormatterTest : YapiSpringClassExporterBaseTest() { "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"200\\\"},\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"ok\\\"},\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/get/{id}\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"get user info\",\"path\":\"/user/get/{id}\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[\"deprecated\"],\"req_query\":[{\"name\":\"id\",\"value\":0,\"desc\":\"user id\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"undone\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[2]).toJson() ) + assertEquals( + "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"200\\\"},\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"ok\\\"},\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/admin/add\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"type\":\"static\",\"title\":\"create an user\",\"req_body_form\":[],\"req_body_is_json_schema\":true,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\",\"queryPath\":{\"params\":[]},\"path\":\"/user/add\"},{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"200\\\"},\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"ok\\\"},\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/admin/add\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"type\":\"static\",\"title\":\"[admin]create an user\",\"req_body_form\":[],\"req_body_is_json_schema\":true,\"__v\":0,\"markdown\":\"[admin]\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"[admin]

\",\"queryPath\":{\"params\":[],\"path\":\"/user/add\"},\"path\":\"/user/admin/add\"}]", + yapiFormatter.doc2Items(requests[3]).toJson() + ) val apiCntInUserCtrl = userCtrlPsiClass.methods.size assertEquals( "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/ctrl/name\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"current ctrl name\",\"path\":\"/default/ctrl/name\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\"}]", @@ -179,6 +188,10 @@ internal abstract class YapiFormatterTest : YapiSpringClassExporterBaseTest() { "[{\"res_body\":\"{\\n \\\"code\\\": \\\"200\\\", //response code\\n \\\"msg\\\": \\\"ok\\\", //message\\n \\\"data\\\": { //response data\\n \\\"id\\\": \\\"666\\\", //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\\\": \\\"@pick([1,2,3])\\\",\\n \\\"name\\\": \\\"tangcent\\\", //user name\\n \\\"age\\\": \\\"18\\\", //user age\\n \\\"sex\\\": \\\"1\\\",\\n \\\"birthDay\\\": \\\"@date\\\", //user birthDay\\n \\\"regtime\\\": \\\"@datetime\\\" //user regtime\\n }\\n}\",\"query_path\":{\"path\":\"/user/get/{id}\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"get user info\",\"path\":\"/user/get/{id}\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[\"deprecated\"],\"req_query\":[{\"name\":\"id\",\"value\":0,\"desc\":\"user id\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"undone\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[2]).toJson()!!.toUnixString() ) + assertEquals( + "[{\"res_body\":\"{\\n \\\"code\\\": \\\"200\\\", //response code\\n \\\"msg\\\": \\\"ok\\\", //message\\n \\\"data\\\": { //response data\\n \\\"id\\\": \\\"666\\\", //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\\\": \\\"@pick([1,2,3])\\\",\\n \\\"name\\\": \\\"tangcent\\\", //user name\\n \\\"age\\\": \\\"18\\\", //user age\\n \\\"sex\\\": \\\"1\\\",\\n \\\"birthDay\\\": \\\"@date\\\", //user birthDay\\n \\\"regtime\\\": \\\"@datetime\\\" //user regtime\\n }\\n}\",\"query_path\":{\"path\":\"/user/admin/add\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\n \\\"id\\\": \\\"666\\\", //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\\\": \\\"@pick([1,2,3])\\\",\\n \\\"name\\\": \\\"tangcent\\\", //user name\\n \\\"age\\\": \\\"18\\\", //user age\\n \\\"sex\\\": \\\"1\\\",\\n \\\"birthDay\\\": \\\"@date\\\", //user birthDay\\n \\\"regtime\\\": \\\"@datetime\\\" //user regtime\\n}\",\"type\":\"static\",\"title\":\"create an user\",\"req_body_form\":[],\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"

\",\"queryPath\":{\"params\":[]},\"path\":\"/user/add\"},{\"res_body\":\"{\\n \\\"code\\\": \\\"200\\\", //response code\\n \\\"msg\\\": \\\"ok\\\", //message\\n \\\"data\\\": { //response data\\n \\\"id\\\": \\\"666\\\", //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\\\": \\\"@pick([1,2,3])\\\",\\n \\\"name\\\": \\\"tangcent\\\", //user name\\n \\\"age\\\": \\\"18\\\", //user age\\n \\\"sex\\\": \\\"1\\\",\\n \\\"birthDay\\\": \\\"@date\\\", //user birthDay\\n \\\"regtime\\\": \\\"@datetime\\\" //user regtime\\n }\\n}\",\"query_path\":{\"path\":\"/user/admin/add\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\n \\\"id\\\": \\\"666\\\", //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\\\": \\\"@pick([1,2,3])\\\",\\n \\\"name\\\": \\\"tangcent\\\", //user name\\n \\\"age\\\": \\\"18\\\", //user age\\n \\\"sex\\\": \\\"1\\\",\\n \\\"birthDay\\\": \\\"@date\\\", //user birthDay\\n \\\"regtime\\\": \\\"@datetime\\\" //user regtime\\n}\",\"type\":\"static\",\"title\":\"[admin]create an user\",\"req_body_form\":[],\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"[admin]\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"[admin]

\",\"queryPath\":{\"params\":[],\"path\":\"/user/add\"},\"path\":\"/user/admin/add\"}]", + yapiFormatter.doc2Items(requests[3]).toJson()!!.toUnixString() + ) val apiCntInUserCtrl = userCtrlPsiClass.methods.size @@ -203,18 +216,21 @@ internal abstract class YapiFormatterTest : YapiSpringClassExporterBaseTest() { class YapiFormatterWithDemoTest : YapiFormatterTest() { override fun customConfig(): String { - return "method.additional.header[!@com.itangcent.annotation.Public]={name: \"token\",value: \"\",desc: \"auth token\",required:true, demo:\"123456\"}\n" + - "#[converts]*\n" + - "#The ObjectId and Date will be parsed as strings\n" + - "json.rule.convert[org.bson.types.ObjectId]=java.lang.String\n" + - "json.rule.convert[java.util.Date]=java.lang.String\n" + - "json.rule.convert[java.sql.Timestamp]=java.lang.String\n" + - "json.rule.convert[java.time.LocalDateTime]=java.lang.String\n" + - "json.rule.convert[java.time.LocalDate]=java.lang.String\n" + - "field.demo=#demo\n" + - "api.open=@com.itangcent.annotation.Public\n" + - "api.status[#undone]=undone\n" + - "api.tag[@java.lang.Deprecated]=deprecated" + + return """${super.customConfig()} + method.additional.header[!@com.itangcent.annotation.Public]={name: "token",value: "",desc: "auth token",required:true, demo:"123456"} + #[converts]* + #The ObjectId and Date will be parsed as strings + json.rule.convert[org.bson.types.ObjectId]=java.lang.String + json.rule.convert[java.util.Date]=java.lang.String + json.rule.convert[java.sql.Timestamp]=java.lang.String + json.rule.convert[java.time.LocalDateTime]=java.lang.String + json.rule.convert[java.time.LocalDate]=java.lang.String + field.demo=#demo + api.open=@com.itangcent.annotation.Public + api.status[#undone]=undone + api.tag[@java.lang.Deprecated]=deprecated + """ } /** @@ -232,32 +248,36 @@ internal abstract class YapiFormatterTest : YapiSpringClassExporterBaseTest() { }) boundary.waitComplete() assertEquals( - "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/ctrl/name\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"current ctrl name\",\"path\":\"/user/ctrl/name\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\"}]", + "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/ctrl/name\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"current ctrl name\",\"path\":\"/user/ctrl/name\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[0]).toJson() ) assertEquals( - "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/greeting\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"say hello\",\"path\":\"/user/greeting\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"not update anything\",\"req_headers\":[],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":true,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

not update anything

\"}]", + "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/greeting\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"say hello\",\"path\":\"/user/greeting\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"not update anything\",\"req_headers\":[],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":true,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

not update anything

\"}]", yapiFormatter.doc2Items(requests[1]).toJson() ) assertEquals( - "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"}},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"user name\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/get/{id}\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"get user info\",\"path\":\"/user/get/{id}\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[\"deprecated\"],\"req_query\":[{\"name\":\"id\",\"value\":0,\"desc\":\"user id\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"undone\",\"desc\":\"

\"}]", + "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"200\\\"},\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"ok\\\"},\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/get/{id}\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"get user info\",\"path\":\"/user/get/{id}\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[\"deprecated\"],\"req_query\":[{\"name\":\"id\",\"value\":0,\"desc\":\"user id\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"undone\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[2]).toJson() ) + assertEquals( + "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"200\\\"},\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"ok\\\"},\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/admin/add\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"type\":\"static\",\"title\":\"create an user\",\"req_body_form\":[],\"req_body_is_json_schema\":true,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\",\"queryPath\":{\"params\":[]},\"path\":\"/user/add\"},{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"200\\\"},\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"ok\\\"},\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/user/admin/add\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"user id\\\",\\\"default\\\":\\\"0\\\"},\\\"type\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@pick([1,2,3])\\\"},\\\"description\\\":\\\"user type\\\",\\\"enum\\\":[1,2,3],\\\"enumDesc\\\":\\\"1 :administration\\\\n2 :a person, an animal or a plant\\\\n3 :Anonymous visitor\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"tangcent\\\"},\\\"description\\\":\\\"user name\\\",\\\"default\\\":\\\"tangcent\\\"},\\\"age\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"18\\\"},\\\"description\\\":\\\"user age\\\"},\\\"sex\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"1\\\"},\\\"description\\\":\\\"\\\"},\\\"birthDay\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@date\\\"},\\\"description\\\":\\\"user birthDay\\\"},\\\"regtime\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@datetime\\\"},\\\"description\\\":\\\"user regtime\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"type\":\"static\",\"title\":\"[admin]create an user\",\"req_body_form\":[],\"req_body_is_json_schema\":true,\"__v\":0,\"markdown\":\"[admin]\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"[admin]

\",\"queryPath\":{\"params\":[],\"path\":\"/user/add\"},\"path\":\"/user/admin/add\"}]", + yapiFormatter.doc2Items(requests[3]).toJson() + ) val apiCntInUserCtrl = userCtrlPsiClass.methods.size assertEquals( - "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/ctrl/name\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"current ctrl name\",\"path\":\"/default/ctrl/name\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\"}]", + "[{\"res_body\":\"{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/ctrl/name\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"current ctrl name\",\"path\":\"/default/ctrl/name\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 1]).toJson() ) assertEquals( - "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"aaa\\\":{\\\"type\\\":\\\"string\\\"},\\\"ddd\\\":{\\\"type\\\":\\\"string\\\"}},\\\"description\\\":\\\"\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}},\\\"description\\\":\\\"\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"description\\\":\\\"\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/query\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with query\",\"path\":\"/default/query\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[{\"name\":\"intArr[0]\",\"value\":666,\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"intArr[1]\",\"value\":888,\"example\":\"888\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.aaa\",\"value\":\"666\",\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.ddd\",\"value\":\"888\",\"example\":\"888\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[0]\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[1]\",\"value\":\"666\",\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"invalid[0]\",\"value\":\"\",\"example\":\"{\\\"aaa\\\",\\\"666\\\"]\",\"desc\":\"\",\"required\":0},{\"name\":\"model.str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"model.integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"model.stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"model.integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"model.s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"model.s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[0].str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"modelList[0].integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"modelList[0].stringList[0]\",\"value\":\"\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"modelList[0].integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"modelList[1].s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[1].s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[1].stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\"}]", + "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"200\\\"},\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"ok\\\"},\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[123, 456]\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"abc\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"123\\\"},\\\"def\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"456\\\"},\\\"aaa\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"ddd\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"{\\\\\\\"abc\\\\\\\":\\\\\\\"123\\\\\\\",\\\\\\\"def\\\\\\\":\\\\\\\"456\\\\\\\"}\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"]\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"}\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"description\\\":\\\"stringList field\\\",\\\"default\\\":\\\"abc\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"}},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"aaa\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"bbb\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"}},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}}\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/query\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with query\",\"path\":\"/default/query\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[{\"name\":\"intArr[0]\",\"value\":123,\"example\":\"123\",\"desc\":\"\",\"required\":0},{\"name\":\"intArr[1]\",\"value\":456,\"example\":\"456\",\"desc\":\"\",\"required\":0},{\"name\":\"intArr[2]\",\"value\":666,\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"intArr[3]\",\"value\":888,\"example\":\"888\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.abc\",\"value\":\"123\",\"example\":\"123\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.def\",\"value\":\"456\",\"example\":\"456\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.aaa\",\"value\":\"666\",\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.ddd\",\"value\":\"888\",\"example\":\"888\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[0]\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[1]\",\"value\":\"123\",\"example\":\"123\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[2]\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[3]\",\"value\":\"666\",\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"invalid[0]\",\"value\":\"\",\"example\":\"{\\\"aaa\\\",\\\"666\\\"]\",\"desc\":\"\",\"required\":0},{\"name\":\"model.str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"model.integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"model.stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"model.integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"model.s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"model.s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[0].str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"modelList[0].integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"modelList[0].stringList[0]\",\"value\":\"\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"modelList[0].integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"modelList[1].s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[1].s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[1].stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 2]).toJson() ) assertEquals( - "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"aaa\\\":{\\\"type\\\":\\\"string\\\"},\\\"ddd\\\":{\\\"type\\\":\\\"string\\\"}},\\\"description\\\":\\\"\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}},\\\"description\\\":\\\"\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"description\\\":\\\"\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/form\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"form\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with form\",\"req_body_form\":[{\"name\":\"intArr[0]\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"intArr[1]\",\"example\":\"888\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.aaa\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.ddd\",\"example\":\"888\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[0]\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[1]\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"invalid[0]\",\"example\":\"{\\\"aaa\\\",\\\"666\\\"]\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"model.integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"model.stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"model.integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"model.s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[0].str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"modelList[0].integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"modelList[0].stringList[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"modelList[0].integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"modelList[1].s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[1].s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[1].stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"\"}],\"path\":\"/default/form\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"multipart/form-data\",\"example\":\"multipart/form-data\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\"}]", + "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"200\\\"},\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"ok\\\"},\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[123, 456]\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"abc\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"123\\\"},\\\"def\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"456\\\"},\\\"aaa\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"ddd\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"{\\\\\\\"abc\\\\\\\":\\\\\\\"123\\\\\\\",\\\\\\\"def\\\\\\\":\\\\\\\"456\\\\\\\"}\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"]\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"}\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"description\\\":\\\"stringList field\\\",\\\"default\\\":\\\"abc\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"}},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"aaa\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"bbb\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"}},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}}\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/form\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"form\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with form\",\"req_body_form\":[{\"name\":\"intArr[0]\",\"example\":\"123\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"intArr[1]\",\"example\":\"456\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"intArr[2]\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"intArr[3]\",\"example\":\"888\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.abc\",\"example\":\"123\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.def\",\"example\":\"456\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.aaa\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.ddd\",\"example\":\"888\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[0]\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[1]\",\"example\":\"123\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[2]\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[3]\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"invalid[0]\",\"example\":\"{\\\"aaa\\\",\\\"666\\\"]\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"model.integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"model.stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"model.integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"model.s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[0].str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"modelList[0].integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"modelList[0].stringList[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"modelList[0].integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"modelList[1].s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[1].s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[1].stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"\"}],\"path\":\"/default/form\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"multipart/form-data\",\"example\":\"multipart/form-data\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 3]).toJson() ) assertEquals( - "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"aaa\\\":{\\\"type\\\":\\\"string\\\"},\\\"ddd\\\":{\\\"type\\\":\\\"string\\\"}},\\\"description\\\":\\\"\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}},\\\"description\\\":\\\"\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"description\\\":\\\"\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"aaa\\\":{\\\"type\\\":\\\"string\\\"},\\\"ddd\\\":{\\\"type\\\":\\\"string\\\"}},\\\"description\\\":\\\"\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\"}},\\\"description\\\":\\\"\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\"},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"description\\\":\\\"\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"type\":\"static\",\"title\":\"call with body\",\"req_body_form\":[],\"path\":\"/default/body\",\"req_body_is_json_schema\":true,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\"}]", + "[{\"res_body\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"code\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"200\\\"},\\\"description\\\":\\\"response code\\\"},\\\"msg\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"ok\\\"},\\\"description\\\":\\\"message\\\"},\\\"data\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[123, 456]\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"abc\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"123\\\"},\\\"def\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"456\\\"},\\\"aaa\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"ddd\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"{\\\\\\\"abc\\\\\\\":\\\\\\\"123\\\\\\\",\\\\\\\"def\\\\\\\":\\\\\\\"456\\\\\\\"}\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"]\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"}\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"description\\\":\\\"stringList field\\\",\\\"default\\\":\\\"abc\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"}},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"aaa\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"bbb\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"}},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}}\\\"}},\\\"description\\\":\\\"response data\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"intArr\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[123, 456]\\\"},\\\"amount\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"abc\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"123\\\"},\\\"def\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"456\\\"},\\\"aaa\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"ddd\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"{\\\\\\\"abc\\\\\\\":\\\\\\\"123\\\\\\\",\\\\\\\"def\\\\\\\":\\\\\\\"456\\\\\\\"}\\\"},\\\"strings\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"]\\\"},\\\"invalid\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[\\\\\\\"abc\\\\\\\",\\\\\\\"123\\\\\\\"}\\\"},\\\"model\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"description\\\":\\\"stringList field\\\",\\\"default\\\":\\\"abc\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"}},\\\"description\\\":\\\"integerArray field\\\"},\\\"s\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"aaa\\\"},\\\"s2\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"default\\\":\\\"bbb\\\"}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}\\\"},\\\"modelList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"str\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"},\\\"description\\\":\\\"string field\\\"},\\\"integer\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"},\\\"description\\\":\\\"integer field\\\"},\\\"stringList\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"mock\\\":{\\\"mock\\\":\\\"str\\\"}},\\\"description\\\":\\\"stringList field\\\"},\\\"integerArray\\\":{\\\"type\\\":\\\"array\\\",\\\"items\\\":{\\\"type\\\":\\\"integer\\\",\\\"mock\\\":{\\\"mock\\\":\\\"666\\\"}},\\\"description\\\":\\\"integerArray field\\\"}}},\\\"description\\\":\\\"\\\",\\\"default\\\":\\\"[{\\\\\\\"s\\\\\\\":\\\\\\\"aaa\\\\\\\",\\\\\\\"s2\\\\\\\":\\\\\\\"bbb\\\\\\\",\\\\\\\"stringList\\\\\\\":\\\\\\\"abc\\\\\\\"}}\\\"}},\\\"\$schema\\\":\\\"http://json-schema.org/draft-04/schema#\\\"}\",\"type\":\"static\",\"title\":\"call with body\",\"req_body_form\":[],\"path\":\"/default/body\",\"req_body_is_json_schema\":true,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":true,\"status\":\"done\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 4]).toJson() ) } @@ -287,9 +307,13 @@ internal abstract class YapiFormatterTest : YapiSpringClassExporterBaseTest() { yapiFormatter.doc2Items(requests[1]).toJson()!!.toUnixString() ) assertEquals( - "[{\"res_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\\\": \\\"@pick([1,2,3])\\\",\\n \\\"name\\\": \\\"Tony Stark\\\", //user name\\n \\\"age\\\": 45, //user age\\n \\\"sex\\\": 0,\\n \\\"birthDay\\\": \\\"\\\", //user birthDay\\n \\\"regtime\\\": \\\"\\\" //user regtime\\n }\\n}\",\"query_path\":{\"path\":\"/user/get/{id}\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"get user info\",\"path\":\"/user/get/{id}\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[\"deprecated\"],\"req_query\":[{\"name\":\"id\",\"value\":0,\"desc\":\"user id\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"undone\",\"desc\":\"

\"}]", + "[{\"res_body\":\"{\\n \\\"code\\\": \\\"200\\\", //response code\\n \\\"msg\\\": \\\"ok\\\", //message\\n \\\"data\\\": { //response data\\n \\\"id\\\": \\\"666\\\", //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\\\": \\\"@pick([1,2,3])\\\",\\n \\\"name\\\": \\\"tangcent\\\", //user name\\n \\\"age\\\": \\\"18\\\", //user age\\n \\\"sex\\\": \\\"1\\\",\\n \\\"birthDay\\\": \\\"@date\\\", //user birthDay\\n \\\"regtime\\\": \\\"@datetime\\\" //user regtime\\n }\\n}\",\"query_path\":{\"path\":\"/user/get/{id}\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"get user info\",\"path\":\"/user/get/{id}\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[\"deprecated\"],\"req_query\":[{\"name\":\"id\",\"value\":0,\"desc\":\"user id\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"undone\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[2]).toJson()!!.toUnixString() ) + assertEquals( + "[{\"res_body\":\"{\\n \\\"code\\\": \\\"200\\\", //response code\\n \\\"msg\\\": \\\"ok\\\", //message\\n \\\"data\\\": { //response data\\n \\\"id\\\": \\\"666\\\", //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\\\": \\\"@pick([1,2,3])\\\",\\n \\\"name\\\": \\\"tangcent\\\", //user name\\n \\\"age\\\": \\\"18\\\", //user age\\n \\\"sex\\\": \\\"1\\\",\\n \\\"birthDay\\\": \\\"@date\\\", //user birthDay\\n \\\"regtime\\\": \\\"@datetime\\\" //user regtime\\n }\\n}\",\"query_path\":{\"path\":\"/user/admin/add\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\n \\\"id\\\": \\\"666\\\", //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\\\": \\\"@pick([1,2,3])\\\",\\n \\\"name\\\": \\\"tangcent\\\", //user name\\n \\\"age\\\": \\\"18\\\", //user age\\n \\\"sex\\\": \\\"1\\\",\\n \\\"birthDay\\\": \\\"@date\\\", //user birthDay\\n \\\"regtime\\\": \\\"@datetime\\\" //user regtime\\n}\",\"type\":\"static\",\"title\":\"create an user\",\"req_body_form\":[],\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"

\",\"queryPath\":{\"params\":[]},\"path\":\"/user/add\"},{\"res_body\":\"{\\n \\\"code\\\": \\\"200\\\", //response code\\n \\\"msg\\\": \\\"ok\\\", //message\\n \\\"data\\\": { //response data\\n \\\"id\\\": \\\"666\\\", //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\\\": \\\"@pick([1,2,3])\\\",\\n \\\"name\\\": \\\"tangcent\\\", //user name\\n \\\"age\\\": \\\"18\\\", //user age\\n \\\"sex\\\": \\\"1\\\",\\n \\\"birthDay\\\": \\\"@date\\\", //user birthDay\\n \\\"regtime\\\": \\\"@datetime\\\" //user regtime\\n }\\n}\",\"query_path\":{\"path\":\"/user/admin/add\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\n \\\"id\\\": \\\"666\\\", //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\\\": \\\"@pick([1,2,3])\\\",\\n \\\"name\\\": \\\"tangcent\\\", //user name\\n \\\"age\\\": \\\"18\\\", //user age\\n \\\"sex\\\": \\\"1\\\",\\n \\\"birthDay\\\": \\\"@date\\\", //user birthDay\\n \\\"regtime\\\": \\\"@datetime\\\" //user regtime\\n}\",\"type\":\"static\",\"title\":\"[admin]create an user\",\"req_body_form\":[],\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"[admin]\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"[admin]

\",\"queryPath\":{\"params\":[],\"path\":\"/user/add\"},\"path\":\"/user/admin/add\"}]", + yapiFormatter.doc2Items(requests[3]).toJson()!!.toUnixString() + ) val apiCntInUserCtrl = userCtrlPsiClass.methods.size @@ -298,15 +322,15 @@ internal abstract class YapiFormatterTest : YapiSpringClassExporterBaseTest() { yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 1]).toJson()!!.toUnixString() ) assertEquals( - "[{\"res_body\":\"{\\n \\\"code\\\": 0, //response code\\n \\\"msg\\\": \\\"\\\", //message\\n \\\"data\\\": { //response data\\n \\\"intArr\\\": [\\n 666,\\n 888\\n ],\\n \\\"amount\\\": {\\n \\\"aaa\\\": \\\"666\\\",\\n \\\"ddd\\\": \\\"888\\\"\\n },\\n \\\"strings\\\": [\\n \\\"aaa\\\",\\n \\\"666\\\"\\n ],\\n \\\"invalid\\\": [\\n \\\"\\\"\\n ],\\n \\\"model\\\": {\\n \\\"str\\\": \\\"\\\", //string field\\n \\\"integer\\\": 0, //integer field\\n \\\"stringList\\\": \\\"abc\\\", //stringList field\\n \\\"integerArray\\\": [ //integerArray field\\n 0\\n ],\\n \\\"s\\\": \\\"aaa\\\",\\n \\\"s2\\\": \\\"bbb\\\"\\n },\\n \\\"modelList\\\": [\\n {\\n \\\"str\\\": \\\"\\\", //string field\\n \\\"integer\\\": 0, //integer field\\n \\\"stringList\\\": [ //stringList field\\n \\\"\\\"\\n ],\\n \\\"integerArray\\\": [ //integerArray field\\n 0\\n ]\\n },\\n {\\n \\\"s\\\": \\\"aaa\\\",\\n \\\"s2\\\": \\\"bbb\\\",\\n \\\"stringList\\\": \\\"abc\\\"\\n }\\n ]\\n }\\n}\",\"query_path\":{\"path\":\"/default/query\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with query\",\"path\":\"/default/query\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[{\"name\":\"intArr[0]\",\"value\":666,\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"intArr[1]\",\"value\":888,\"example\":\"888\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.aaa\",\"value\":\"666\",\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.ddd\",\"value\":\"888\",\"example\":\"888\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[0]\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[1]\",\"value\":\"666\",\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"invalid[0]\",\"value\":\"\",\"example\":\"{\\\"aaa\\\",\\\"666\\\"]\",\"desc\":\"\",\"required\":0},{\"name\":\"model.str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"model.integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"model.stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"model.integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"model.s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"model.s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[0].str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"modelList[0].integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"modelList[0].stringList[0]\",\"value\":\"\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"modelList[0].integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"modelList[1].s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[1].s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[1].stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"

\"}]", + "[{\"res_body\":\"{\\n \\\"code\\\": \\\"200\\\", //response code\\n \\\"msg\\\": \\\"ok\\\", //message\\n \\\"data\\\": { //response data\\n \\\"intArr\\\": [\\n \\\"666\\\",\\n \\\"666\\\",\\n \\\"666\\\",\\n \\\"666\\\"\\n ],\\n \\\"amount\\\": {\\n \\\"abc\\\": \\\"str\\\",\\n \\\"def\\\": \\\"str\\\",\\n \\\"aaa\\\": \\\"str\\\",\\n \\\"ddd\\\": \\\"str\\\"\\n },\\n \\\"strings\\\": [\\n \\\"str\\\",\\n \\\"str\\\",\\n \\\"str\\\",\\n \\\"str\\\"\\n ],\\n \\\"invalid\\\": [\\n \\\"str\\\"\\n ],\\n \\\"model\\\": {\\n \\\"str\\\": \\\"str\\\", //string field\\n \\\"integer\\\": \\\"666\\\", //integer field\\n \\\"stringList\\\": \\\"str\\\", //stringList field\\n \\\"integerArray\\\": [ //integerArray field\\n \\\"666\\\"\\n ],\\n \\\"s\\\": \\\"str\\\",\\n \\\"s2\\\": \\\"str\\\"\\n },\\n \\\"modelList\\\": [\\n {\\n \\\"str\\\": \\\"str\\\", //string field\\n \\\"integer\\\": \\\"666\\\", //integer field\\n \\\"stringList\\\": [ //stringList field\\n \\\"str\\\"\\n ],\\n \\\"integerArray\\\": [ //integerArray field\\n \\\"666\\\"\\n ]\\n },\\n {\\n \\\"s\\\": \\\"str\\\",\\n \\\"s2\\\": \\\"str\\\",\\n \\\"stringList\\\": \\\"str\\\"\\n }\\n ]\\n }\\n}\",\"query_path\":{\"path\":\"/default/query\",\"params\":[]},\"method\":\"GET\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with query\",\"path\":\"/default/query\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[{\"name\":\"intArr[0]\",\"value\":123,\"example\":\"123\",\"desc\":\"\",\"required\":0},{\"name\":\"intArr[1]\",\"value\":456,\"example\":\"456\",\"desc\":\"\",\"required\":0},{\"name\":\"intArr[2]\",\"value\":666,\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"intArr[3]\",\"value\":888,\"example\":\"888\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.abc\",\"value\":\"123\",\"example\":\"123\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.def\",\"value\":\"456\",\"example\":\"456\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.aaa\",\"value\":\"666\",\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"amount.ddd\",\"value\":\"888\",\"example\":\"888\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[0]\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[1]\",\"value\":\"123\",\"example\":\"123\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[2]\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"strings[3]\",\"value\":\"666\",\"example\":\"666\",\"desc\":\"\",\"required\":0},{\"name\":\"invalid[0]\",\"value\":\"\",\"example\":\"{\\\"aaa\\\",\\\"666\\\"]\",\"desc\":\"\",\"required\":0},{\"name\":\"model.str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"model.integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"model.stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"model.integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"model.s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"model.s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[0].str\",\"value\":\"\",\"desc\":\"string field\",\"required\":0},{\"name\":\"modelList[0].integer\",\"value\":0,\"desc\":\"integer field\",\"required\":0},{\"name\":\"modelList[0].stringList[0]\",\"value\":\"\",\"desc\":\"stringList field\",\"required\":0},{\"name\":\"modelList[0].integerArray[0]\",\"value\":0,\"desc\":\"integerArray field\",\"required\":0},{\"name\":\"modelList[1].s\",\"value\":\"aaa\",\"example\":\"aaa\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[1].s2\",\"value\":\"bbb\",\"example\":\"bbb\",\"desc\":\"\",\"required\":0},{\"name\":\"modelList[1].stringList\",\"value\":\"abc\",\"example\":\"abc\",\"desc\":\"\",\"required\":0}],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 2]).toJson()!!.toUnixString() ) assertEquals( - "[{\"res_body\":\"{\\n \\\"code\\\": 0, //response code\\n \\\"msg\\\": \\\"\\\", //message\\n \\\"data\\\": { //response data\\n \\\"intArr\\\": [\\n 666,\\n 888\\n ],\\n \\\"amount\\\": {\\n \\\"aaa\\\": \\\"666\\\",\\n \\\"ddd\\\": \\\"888\\\"\\n },\\n \\\"strings\\\": [\\n \\\"aaa\\\",\\n \\\"666\\\"\\n ],\\n \\\"invalid\\\": [\\n \\\"\\\"\\n ],\\n \\\"model\\\": {\\n \\\"str\\\": \\\"\\\", //string field\\n \\\"integer\\\": 0, //integer field\\n \\\"stringList\\\": \\\"abc\\\", //stringList field\\n \\\"integerArray\\\": [ //integerArray field\\n 0\\n ],\\n \\\"s\\\": \\\"aaa\\\",\\n \\\"s2\\\": \\\"bbb\\\"\\n },\\n \\\"modelList\\\": [\\n {\\n \\\"str\\\": \\\"\\\", //string field\\n \\\"integer\\\": 0, //integer field\\n \\\"stringList\\\": [ //stringList field\\n \\\"\\\"\\n ],\\n \\\"integerArray\\\": [ //integerArray field\\n 0\\n ]\\n },\\n {\\n \\\"s\\\": \\\"aaa\\\",\\n \\\"s2\\\": \\\"bbb\\\",\\n \\\"stringList\\\": \\\"abc\\\"\\n }\\n ]\\n }\\n}\",\"query_path\":{\"path\":\"/default/form\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"form\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with form\",\"req_body_form\":[{\"name\":\"intArr[0]\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"intArr[1]\",\"example\":\"888\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.aaa\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.ddd\",\"example\":\"888\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[0]\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[1]\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"invalid[0]\",\"example\":\"{\\\"aaa\\\",\\\"666\\\"]\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"model.integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"model.stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"model.integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"model.s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[0].str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"modelList[0].integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"modelList[0].stringList[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"modelList[0].integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"modelList[1].s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[1].s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[1].stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"\"}],\"path\":\"/default/form\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"multipart/form-data\",\"example\":\"multipart/form-data\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"

\"}]", + "[{\"res_body\":\"{\\n \\\"code\\\": \\\"200\\\", //response code\\n \\\"msg\\\": \\\"ok\\\", //message\\n \\\"data\\\": { //response data\\n \\\"intArr\\\": [\\n \\\"666\\\",\\n \\\"666\\\",\\n \\\"666\\\",\\n \\\"666\\\"\\n ],\\n \\\"amount\\\": {\\n \\\"abc\\\": \\\"str\\\",\\n \\\"def\\\": \\\"str\\\",\\n \\\"aaa\\\": \\\"str\\\",\\n \\\"ddd\\\": \\\"str\\\"\\n },\\n \\\"strings\\\": [\\n \\\"str\\\",\\n \\\"str\\\",\\n \\\"str\\\",\\n \\\"str\\\"\\n ],\\n \\\"invalid\\\": [\\n \\\"str\\\"\\n ],\\n \\\"model\\\": {\\n \\\"str\\\": \\\"str\\\", //string field\\n \\\"integer\\\": \\\"666\\\", //integer field\\n \\\"stringList\\\": \\\"str\\\", //stringList field\\n \\\"integerArray\\\": [ //integerArray field\\n \\\"666\\\"\\n ],\\n \\\"s\\\": \\\"str\\\",\\n \\\"s2\\\": \\\"str\\\"\\n },\\n \\\"modelList\\\": [\\n {\\n \\\"str\\\": \\\"str\\\", //string field\\n \\\"integer\\\": \\\"666\\\", //integer field\\n \\\"stringList\\\": [ //stringList field\\n \\\"str\\\"\\n ],\\n \\\"integerArray\\\": [ //integerArray field\\n \\\"666\\\"\\n ]\\n },\\n {\\n \\\"s\\\": \\\"str\\\",\\n \\\"s2\\\": \\\"str\\\",\\n \\\"stringList\\\": \\\"str\\\"\\n }\\n ]\\n }\\n}\",\"query_path\":{\"path\":\"/default/form\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"form\",\"res_body_type\":\"json\",\"index\":0,\"type\":\"static\",\"title\":\"call with form\",\"req_body_form\":[{\"name\":\"intArr[0]\",\"example\":\"123\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"intArr[1]\",\"example\":\"456\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"intArr[2]\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"intArr[3]\",\"example\":\"888\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.abc\",\"example\":\"123\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.def\",\"example\":\"456\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.aaa\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"amount.ddd\",\"example\":\"888\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[0]\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[1]\",\"example\":\"123\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[2]\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"strings[3]\",\"example\":\"666\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"invalid[0]\",\"example\":\"{\\\"aaa\\\",\\\"666\\\"]\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"model.integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"model.stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"model.integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"model.s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"model.s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[0].str\",\"type\":\"text\",\"required\":0,\"desc\":\"string field\"},{\"name\":\"modelList[0].integer\",\"type\":\"text\",\"required\":0,\"desc\":\"integer field\"},{\"name\":\"modelList[0].stringList[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"stringList field\"},{\"name\":\"modelList[0].integerArray[0]\",\"type\":\"text\",\"required\":0,\"desc\":\"integerArray field\"},{\"name\":\"modelList[1].s\",\"example\":\"aaa\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[1].s2\",\"example\":\"bbb\",\"type\":\"text\",\"required\":0,\"desc\":\"\"},{\"name\":\"modelList[1].stringList\",\"example\":\"abc\",\"type\":\"text\",\"required\":0,\"desc\":\"\"}],\"path\":\"/default/form\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"multipart/form-data\",\"example\":\"multipart/form-data\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 3]).toJson()!!.toUnixString() ) assertEquals( - "[{\"res_body\":\"{\\n \\\"code\\\": 0, //response code\\n \\\"msg\\\": \\\"\\\", //message\\n \\\"data\\\": { //response data\\n \\\"intArr\\\": [\\n 666,\\n 888\\n ],\\n \\\"amount\\\": {\\n \\\"aaa\\\": \\\"666\\\",\\n \\\"ddd\\\": \\\"888\\\"\\n },\\n \\\"strings\\\": [\\n \\\"aaa\\\",\\n \\\"666\\\"\\n ],\\n \\\"invalid\\\": [\\n \\\"\\\"\\n ],\\n \\\"model\\\": {\\n \\\"str\\\": \\\"\\\", //string field\\n \\\"integer\\\": 0, //integer field\\n \\\"stringList\\\": \\\"abc\\\", //stringList field\\n \\\"integerArray\\\": [ //integerArray field\\n 0\\n ],\\n \\\"s\\\": \\\"aaa\\\",\\n \\\"s2\\\": \\\"bbb\\\"\\n },\\n \\\"modelList\\\": [\\n {\\n \\\"str\\\": \\\"\\\", //string field\\n \\\"integer\\\": 0, //integer field\\n \\\"stringList\\\": [ //stringList field\\n \\\"\\\"\\n ],\\n \\\"integerArray\\\": [ //integerArray field\\n 0\\n ]\\n },\\n {\\n \\\"s\\\": \\\"aaa\\\",\\n \\\"s2\\\": \\\"bbb\\\",\\n \\\"stringList\\\": \\\"abc\\\"\\n }\\n ]\\n }\\n}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\n \\\"intArr\\\": [\\n 666,\\n 888\\n ],\\n \\\"amount\\\": {\\n \\\"aaa\\\": \\\"666\\\",\\n \\\"ddd\\\": \\\"888\\\"\\n },\\n \\\"strings\\\": [\\n \\\"aaa\\\",\\n \\\"666\\\"\\n ],\\n \\\"invalid\\\": [\\n \\\"\\\"\\n ],\\n \\\"model\\\": {\\n \\\"str\\\": \\\"\\\", //string field\\n \\\"integer\\\": 0, //integer field\\n \\\"stringList\\\": \\\"abc\\\", //stringList field\\n \\\"integerArray\\\": [ //integerArray field\\n 0\\n ],\\n \\\"s\\\": \\\"aaa\\\",\\n \\\"s2\\\": \\\"bbb\\\"\\n },\\n \\\"modelList\\\": [\\n {\\n \\\"str\\\": \\\"\\\", //string field\\n \\\"integer\\\": 0, //integer field\\n \\\"stringList\\\": [ //stringList field\\n \\\"\\\"\\n ],\\n \\\"integerArray\\\": [ //integerArray field\\n 0\\n ]\\n },\\n {\\n \\\"s\\\": \\\"aaa\\\",\\n \\\"s2\\\": \\\"bbb\\\",\\n \\\"stringList\\\": \\\"abc\\\"\\n }\\n ]\\n}\",\"type\":\"static\",\"title\":\"call with body\",\"req_body_form\":[],\"path\":\"/default/body\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"

\"}]", + "[{\"res_body\":\"{\\n \\\"code\\\": \\\"200\\\", //response code\\n \\\"msg\\\": \\\"ok\\\", //message\\n \\\"data\\\": { //response data\\n \\\"intArr\\\": [\\n \\\"666\\\",\\n \\\"666\\\",\\n \\\"666\\\",\\n \\\"666\\\"\\n ],\\n \\\"amount\\\": {\\n \\\"abc\\\": \\\"str\\\",\\n \\\"def\\\": \\\"str\\\",\\n \\\"aaa\\\": \\\"str\\\",\\n \\\"ddd\\\": \\\"str\\\"\\n },\\n \\\"strings\\\": [\\n \\\"str\\\",\\n \\\"str\\\",\\n \\\"str\\\",\\n \\\"str\\\"\\n ],\\n \\\"invalid\\\": [\\n \\\"str\\\"\\n ],\\n \\\"model\\\": {\\n \\\"str\\\": \\\"str\\\", //string field\\n \\\"integer\\\": \\\"666\\\", //integer field\\n \\\"stringList\\\": \\\"str\\\", //stringList field\\n \\\"integerArray\\\": [ //integerArray field\\n \\\"666\\\"\\n ],\\n \\\"s\\\": \\\"str\\\",\\n \\\"s2\\\": \\\"str\\\"\\n },\\n \\\"modelList\\\": [\\n {\\n \\\"str\\\": \\\"str\\\", //string field\\n \\\"integer\\\": \\\"666\\\", //integer field\\n \\\"stringList\\\": [ //stringList field\\n \\\"str\\\"\\n ],\\n \\\"integerArray\\\": [ //integerArray field\\n \\\"666\\\"\\n ]\\n },\\n {\\n \\\"s\\\": \\\"str\\\",\\n \\\"s2\\\": \\\"str\\\",\\n \\\"stringList\\\": \\\"str\\\"\\n }\\n ]\\n }\\n}\",\"query_path\":{\"path\":\"/default/body\",\"params\":[]},\"method\":\"POST\",\"req_body_type\":\"json\",\"res_body_type\":\"json\",\"index\":0,\"req_body_other\":\"{\\n \\\"intArr\\\": [\\n \\\"666\\\",\\n \\\"666\\\",\\n \\\"666\\\",\\n \\\"666\\\"\\n ],\\n \\\"amount\\\": {\\n \\\"abc\\\": \\\"str\\\",\\n \\\"def\\\": \\\"str\\\",\\n \\\"aaa\\\": \\\"str\\\",\\n \\\"ddd\\\": \\\"str\\\"\\n },\\n \\\"strings\\\": [\\n \\\"str\\\",\\n \\\"str\\\",\\n \\\"str\\\",\\n \\\"str\\\"\\n ],\\n \\\"invalid\\\": [\\n \\\"str\\\"\\n ],\\n \\\"model\\\": {\\n \\\"str\\\": \\\"str\\\", //string field\\n \\\"integer\\\": \\\"666\\\", //integer field\\n \\\"stringList\\\": \\\"str\\\", //stringList field\\n \\\"integerArray\\\": [ //integerArray field\\n \\\"666\\\"\\n ],\\n \\\"s\\\": \\\"str\\\",\\n \\\"s2\\\": \\\"str\\\"\\n },\\n \\\"modelList\\\": [\\n {\\n \\\"str\\\": \\\"str\\\", //string field\\n \\\"integer\\\": \\\"666\\\", //integer field\\n \\\"stringList\\\": [ //stringList field\\n \\\"str\\\"\\n ],\\n \\\"integerArray\\\": [ //integerArray field\\n \\\"666\\\"\\n ]\\n },\\n {\\n \\\"s\\\": \\\"str\\\",\\n \\\"s2\\\": \\\"str\\\",\\n \\\"stringList\\\": \\\"str\\\"\\n }\\n ]\\n}\",\"type\":\"static\",\"title\":\"call with body\",\"req_body_form\":[],\"path\":\"/default/body\",\"req_body_is_json_schema\":false,\"__v\":0,\"markdown\":\"\",\"req_headers\":[{\"name\":\"Content-Type\",\"value\":\"application/json\",\"example\":\"application/json\",\"required\":1},{\"name\":\"token\",\"value\":\"\",\"desc\":\"auth token\",\"example\":\"123456\",\"required\":1}],\"edit_uid\":0,\"up_time\":1618124194,\"tag\":[],\"req_query\":[],\"api_opened\":false,\"add_time\":1618124194,\"res_body_is_json_schema\":false,\"status\":\"done\",\"desc\":\"

\"}]", yapiFormatter.doc2Items(requests[apiCntInUserCtrl + 4]).toJson()!!.toUnixString() ) } diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiSpringClassExporterBaseTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiSpringClassExporterBaseTest.kt index c005b246d..8000afd0e 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiSpringClassExporterBaseTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiSpringClassExporterBaseTest.kt @@ -61,18 +61,28 @@ internal abstract class YapiSpringClassExporterBaseTest : PluginContextLightCode } override fun customConfig(): String { - return "method.additional.header[!@com.itangcent.annotation.Public]={name: \"token\",value: \"\",desc: \"auth token\",required:true, demo:\"123456\"}\n" + - "#[converts]*\n" + - "#The ObjectId and Date will be parsed as strings\n" + - "json.rule.convert[org.bson.types.ObjectId]=java.lang.String\n" + - "json.rule.convert[java.util.Date]=java.lang.String\n" + - "json.rule.convert[java.sql.Timestamp]=java.lang.String\n" + - "json.rule.convert[java.time.LocalDateTime]=java.lang.String\n" + - "json.rule.convert[java.time.LocalDate]=java.lang.String\n" + - "field.default.value=#default\n" + - "api.open=@com.itangcent.annotation.Public\n" + - "api.status[#undone]=undone\n" + - "api.tag[@java.lang.Deprecated]=deprecated" + return """ + method.additional.header[!@com.itangcent.annotation.Public]={name: "token",value: "",desc: "auth token",required:true, demo:"123456"} + #[converts]* + #The ObjectId and Date will be parsed as strings + json.rule.convert[org.bson.types.ObjectId]=java.lang.String + json.rule.convert[java.util.Date]=java.lang.String + json.rule.convert[java.sql.Timestamp]=java.lang.String + json.rule.convert[java.time.LocalDateTime]=java.lang.String + json.rule.convert[java.time.LocalDate]=java.lang.String + field.default.value=#default + api.open=@com.itangcent.annotation.Public + api.status[#undone]=undone + api.tag[@java.lang.Deprecated]=deprecated + path.multi=all + yapi.format.after=groovy:``` + if(url.contains("/admin")){ + item["title"] = "[admin]"+item["title"] + item["markdown"] = "[admin]"+item["markdown"] + item["desc"] = "[admin]"+item["desc"] + } + ``` + """ } override fun bind(builder: ActionContext.ActionContextBuilder) { diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/settings/EnumProcessInitializerTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/settings/EnumProcessInitializerTest.kt index 3cab6cc94..d5c46ddcb 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/settings/EnumProcessInitializerTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/settings/EnumProcessInitializerTest.kt @@ -4,6 +4,7 @@ import com.google.inject.Inject import com.intellij.ide.util.PropertiesComponent import com.itangcent.idea.swing.MessagesHelper import com.itangcent.intellij.context.ActionContext +import com.itangcent.intellij.extend.withBoundary import com.itangcent.mock.SettingBinderAdaptor import com.itangcent.mock.any import com.itangcent.testFramework.PluginContextLightCodeInsightFixtureTestCase @@ -55,9 +56,13 @@ class EnumProcessInitializerTest : PluginContextLightCodeInsightFixtureTestCase( builder.bindInstance(MessagesHelper::class, messagesHelper) } + private fun init() = actionContext.withBoundary { + enumProcessInitializer.init() + } + fun testInitWithNoRecord() { selectedEnumOption = null - enumProcessInitializer.init() + init() settings.recommendConfigs = "" val recommendConfigs = settingBinder.read().recommendConfigs.split(",") assertFalse(recommendConfigs.contains("enum_auto_select_field_by_type")) @@ -70,7 +75,7 @@ class EnumProcessInitializerTest : PluginContextLightCodeInsightFixtureTestCase( PropertiesComponent.getInstance().setValue(EnumProcessInitializer.ENUM_RECOMMEND_ITEMS_CONFIRMED_KEY, false) EventRecords.record(EventRecords.ENUM_RESOLVE) settings.recommendConfigs = "" - enumProcessInitializer.init() + init() val recommendConfigs = settingBinder.read().recommendConfigs.split(",") assertFalse(recommendConfigs.contains("enum_auto_select_field_by_type")) assertFalse(recommendConfigs.contains("enum_use_name")) @@ -83,7 +88,7 @@ class EnumProcessInitializerTest : PluginContextLightCodeInsightFixtureTestCase( PropertiesComponent.getInstance().setValue(EnumProcessInitializer.ENUM_RECOMMEND_ITEMS_CONFIRMED_KEY, false) EventRecords.record(EventRecords.ENUM_RESOLVE) settings.recommendConfigs = "" - enumProcessInitializer.init() + init() val recommendConfigs = settingBinder.read().recommendConfigs.split(",") assertFalse(recommendConfigs.contains("enum_auto_select_field_by_type")) assertFalse(recommendConfigs.contains("enum_use_name")) @@ -96,7 +101,7 @@ class EnumProcessInitializerTest : PluginContextLightCodeInsightFixtureTestCase( EventRecords.record(EventRecords.ENUM_RESOLVE) settings.recommendConfigs = "" run { - enumProcessInitializer.init() + init() val recommendConfigs = settingBinder.read().recommendConfigs.split(",") assertTrue(recommendConfigs.contains("enum_auto_select_field_by_type")) assertFalse(recommendConfigs.contains("enum_use_name")) @@ -105,7 +110,7 @@ class EnumProcessInitializerTest : PluginContextLightCodeInsightFixtureTestCase( run { selectedEnumOption = "enum_use_name" to "" //will not init again - enumProcessInitializer.init() + init() val recommendConfigs = settingBinder.read().recommendConfigs.split(",") assertTrue(recommendConfigs.contains("enum_auto_select_field_by_type")) assertFalse(recommendConfigs.contains("enum_use_name")) diff --git a/idea-plugin/src/test/resources/api/UserCtrl.java b/idea-plugin/src/test/resources/api/UserCtrl.java index 22ba567f0..5acced977 100644 --- a/idea-plugin/src/test/resources/api/UserCtrl.java +++ b/idea-plugin/src/test/resources/api/UserCtrl.java @@ -53,7 +53,7 @@ public IResult get(@PathVariable("id") Long id) { /** * create an user */ - @PostMapping("/add") + @PostMapping({"/add", "/admin/add"}) public Result create(@RequestBody UserInfo userInfo) { return Result.success(userInfo); } diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.CustomizedDirectorySpringMarkdownApiExporterTest.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.CustomizedDirectorySpringMarkdownApiExporterTest.txt index d2bf5cdb0..e63c5fae7 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.CustomizedDirectorySpringMarkdownApiExporterTest.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.CustomizedDirectorySpringMarkdownApiExporterTest.txt @@ -1071,7 +1071,7 @@ access user info > `BASIC` -**`Path params`:** user/add +**`Path params`:** user/add,user/admin/add **`Method`:** POST diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.DirectorySpringMarkdownApiExporterTest.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.DirectorySpringMarkdownApiExporterTest.txt index 78f6dca84..11a316514 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.DirectorySpringMarkdownApiExporterTest.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.DirectorySpringMarkdownApiExporterTest.txt @@ -1071,7 +1071,7 @@ access user info > BASIC -**Path:** user/add +**Path:** user/add,user/admin/add **Method:** POST diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.SpringMarkdownApiExporterTest.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.SpringMarkdownApiExporterTest.txt index 789e86ef4..ab5496fc3 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.SpringMarkdownApiExporterTest.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.SpringMarkdownApiExporterTest.txt @@ -160,7 +160,7 @@ access user info > BASIC -**Path:** user/add +**Path:** user/add,user/admin/add **Method:** POST diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.SpringUltimateMarkdownApiExporterTest.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.SpringUltimateMarkdownApiExporterTest.txt index d4b7e6b50..4ca85cda3 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.SpringUltimateMarkdownApiExporterTest.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.SpringUltimateMarkdownApiExporterTest.txt @@ -160,7 +160,7 @@ access user info > BASIC -**Path:** user/add +**Path:** user/add,user/admin/add **Method:** POST diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequests.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequests.txt index b8b8a8092..03a17ea37 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequests.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequests.txt @@ -314,7 +314,6 @@ }, { "request": { - "method": "POST", "description": "", "header": [ { @@ -330,6 +329,7 @@ "description": "auth token" } ], + "method": "POST", "body": { "mode": "raw", "options": { @@ -340,13 +340,13 @@ "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" ], - "query": [], - "host": "{{test_default}}", - "raw": "{{test_default}}/user/add" + "raw": "{{test_default}}/user/add", + "query": [] } }, "response": [ @@ -379,13 +379,14 @@ "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" ], - "query": [], - "host": "{{test_default}}", - "raw": "{{test_default}}/user/add" + "raw": "{{test_default}}/user/admin/add", + "query": [] } }, "code": 200, @@ -442,6 +443,138 @@ } ] }, + { + "request": { + "description": "[admin]", + "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", + "admin", + "add" + ], + "raw": "{{test_default}}/user/admin/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" + ], + "raw": "{{test_default}}/user/admin/add", + "query": [] + } + }, + "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\": \"\",\n \"data\": {\n \"id\": 0,\n \"type\": 0,\n \"name\": \"\",\n \"age\": 0,\n \"sex\": 0,\n \"birthDay\": \"\",\n \"regtime\": \"\"\n }\n}" + } + ], + "name": "[admin]create an user", + "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" + } + } + ] + }, { "request": { "method": "PUT", diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection.txt index 01726fbec..441d6b3e9 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection.txt @@ -637,7 +637,6 @@ }, { "request": { - "method": "POST", "description": "", "header": [ { @@ -653,6 +652,7 @@ "description": "auth token" } ], + "method": "POST", "body": { "mode": "raw", "options": { @@ -663,13 +663,13 @@ "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" ], - "query": [], - "host": "{{test_default}}", - "raw": "{{test_default}}/user/add" + "raw": "{{test_default}}/user/add", + "query": [] } }, "response": [ @@ -702,13 +702,14 @@ "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" ], - "query": [], - "host": "{{test_default}}", - "raw": "{{test_default}}/user/add" + "raw": "{{test_default}}/user/admin/add", + "query": [] } }, "code": 200, @@ -765,6 +766,138 @@ } ] }, + { + "request": { + "description": "[admin]", + "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", + "admin", + "add" + ], + "raw": "{{test_default}}/user/admin/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" + ], + "raw": "{{test_default}}/user/admin/add", + "query": [] + } + }, + "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\": \"\",\n \"data\": {\n \"id\": 0,\n \"type\": 0,\n \"name\": \"\",\n \"age\": 0,\n \"sex\": 0,\n \"birthDay\": \"\",\n \"regtime\": \"\"\n }\n}" + } + ], + "name": "[admin]create an user", + "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" + } + } + ] + }, { "request": { "method": "PUT", diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsWithWrapCollection.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsWithWrapCollection.txt index b3430fa94..645867d82 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsWithWrapCollection.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsWithWrapCollection.txt @@ -316,7 +316,6 @@ }, { "request": { - "method": "POST", "description": "", "header": [ { @@ -332,6 +331,7 @@ "description": "auth token" } ], + "method": "POST", "body": { "mode": "raw", "options": { @@ -342,13 +342,13 @@ "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": { + "host": "{{test_default}}", "path": [ "user", "add" ], - "query": [], - "host": "{{test_default}}", - "raw": "{{test_default}}/user/add" + "raw": "{{test_default}}/user/add", + "query": [] } }, "response": [ @@ -381,13 +381,14 @@ "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": { + "host": "{{test_default}}", "path": [ "user", + "admin", "add" ], - "query": [], - "host": "{{test_default}}", - "raw": "{{test_default}}/user/add" + "raw": "{{test_default}}/user/admin/add", + "query": [] } }, "code": 200, @@ -444,6 +445,138 @@ } ] }, + { + "request": { + "description": "[admin]", + "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, //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": { + "host": "{{test_default}}", + "path": [ + "user", + "admin", + "add" + ], + "raw": "{{test_default}}/user/admin/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, //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": { + "host": "{{test_default}}", + "path": [ + "user", + "admin", + "add" + ], + "raw": "{{test_default}}/user/admin/add", + "query": [] + } + }, + "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\": \"\", //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\": \"\", //user name\n \"age\": 0, //user age\n \"sex\": 0,\n \"birthDay\": \"\", //user birthDay\n \"regtime\": \"\" //user regtime\n }\n}" + } + ], + "name": "[admin]create an user", + "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" + } + } + ] + }, { "request": { "method": "PUT",