Giter Site home page Giter Site logo

tangcent / easy-yapi Goto Github PK

View Code? Open in Web Editor NEW
419.0 13.0 140.0 26 MB

Generate API document to yapi

Home Page: https://easyyapi.com

License: GNU Affero General Public License v3.0

Kotlin 92.22% HTML 0.08% Shell 0.21% Java 7.48%
yapi-plugin yapi idea-plugin intellij-plugin

easy-yapi's Introduction

easy-yapi

Build Status CI codecov Average time to resolve an issue Percentage of issues still open

Feature

Support Extended Support
language java, kotlin scala
web spring, feign, jaxrs (quarkus or jersey) dubbo
channels Postman, Yapi, Markdown , Curl , HttpClient -
frameworks javax.validation, Jackson, Gson swagger

Navigation

Run application

  • ./gradlew :idea-plugin:runIde will runs an IDEA instance with the EasyYapi installed.
  • ./gradlew clean test will run all test case.

Requirements

  • IDE: Intellij Idea Ultimate / Intellij Idea Community 2021.2.1 or higher
  • JDK: Version 11 or higher

Compatibility

JDK IDE status
11 2021.2.1
15 2022.2.3
17 2023.1.3

Javadoc

KDoc

Contributing

You can propose a feature request opening an issue or a pull request.

Here is a list of contributors:

easy-yapi's People

Contributors

echo-layker avatar gcdd1993 avatar github-actions[bot] avatar heyangli23 avatar jian-cong avatar mizhuo avatar tangcent avatar texousliu avatar visionarygit avatar zjz6b6 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easy-yapi's Issues

接口使用 Enum 类型 export to yapi 僵死

环境:

插件使用目前最新版(Version 1.0.0.183.0.0)
IntelliJ IDEA 2019.2 (Ultimate Edition)
Build #IU-192.5728.98, built on July 23, 2019
Runtime version: 1.8.0_201-b09 amd64

现象:

执行 export 后,日志输出如下:

同时,占用资源迅速飙升到配置上限:
1569486125383-4a0ee9b1-93f8-486b-8990-3f7c8e74013e.png

Intellij 基本僵死,无后续反应。

在执行操作时进行 CPU 抽样,可以见到如下信息:

相关 thread dump 如下:

"ActionContext-1" #226 daemon prio=5 os_prio=0 tid=0x000000006fc92000 nid=0x4144 runnable [0x000000005644b000]
   java.lang.Thread.State: RUNNABLE
        at java.util.HashSet.<init>(HashSet.java:106)
        at kotlin.reflect.jvm.internal.impl.utils.DFS$VisitedWithSet.<init>(DFS.java:136)
        at kotlin.reflect.jvm.internal.impl.utils.DFS.dfs(DFS.java:37)
        at kotlin.reflect.jvm.internal.impl.utils.DFS.ifAny(DFS.java:47)
        at kotlin.reflect.jvm.internal.impl.resolve.descriptorUtil.DescriptorUtilsKt.declaresOrInheritsDefaultValue(DescriptorUtils.kt:188)
        at kotlin.reflect.jvm.internal.KParameterImpl.isOptional(KParameterImpl.kt:61)
        at kotlin.reflect.full.KClasses.createInstance(KClasses.kt:280)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:73)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:74)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:74)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:74)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:74)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$copy$2.accept(AbstractPsiClassHelper.kt:82)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.copy(AbstractPsiClassHelper.kt:81)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.getFields(AbstractPsiClassHelper.kt:253)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.parseFieldOrMethod(AbstractPsiClassHelper.kt:1052)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$getFields$2.invoke(AbstractPsiClassHelper.kt:462)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$getFields$2.invoke(AbstractPsiClassHelper.kt:25)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.foreachField(AbstractPsiClassHelper.kt:496)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.getFields(AbstractPsiClassHelper.kt:445)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.getTypeObject(AbstractPsiClassHelper.kt:421)
        at com.itangcent.idea.utils.CustomizedPsiClassHelper.getTypeObject(CustomizedPsiClassHelper.kt:39)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.getTypeObject(AbstractPsiClassHelper.kt:274)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.getTypeObject(AbstractPsiClassHelper.kt:332)
        at com.itangcent.idea.utils.CustomizedPsiClassHelper.getTypeObject(CustomizedPsiClassHelper.kt:39)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.getTypeObject(AbstractPsiClassHelper.kt:274)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.parseFieldOrMethod(AbstractPsiClassHelper.kt:971)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$getFields$2.invoke(AbstractPsiClassHelper.kt:462)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper$getFields$2.invoke(AbstractPsiClassHelper.kt:25)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.foreachField(AbstractPsiClassHelper.kt:496)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.getFields(AbstractPsiClassHelper.kt:445)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.getTypeObject(AbstractPsiClassHelper.kt:421)
        at com.itangcent.idea.utils.CustomizedPsiClassHelper.getTypeObject(CustomizedPsiClassHelper.kt:39)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.getTypeObject(AbstractPsiClassHelper.kt:274)
        at com.itangcent.intellij.psi.AbstractPsiClassHelper.getTypeObject(AbstractPsiClassHelper.kt:182)
        at com.itangcent.idea.plugin.api.export.AbstractRequestClassExporter.parseResponseBody(AbstractRequestClassExporter.kt:407)
        at com.itangcent.idea.plugin.api.export.AbstractRequestClassExporter.processResponse(AbstractRequestClassExporter.kt:200)
        at com.itangcent.idea.plugin.api.export.AbstractRequestClassExporter.exportMethodApi(AbstractRequestClassExporter.kt:150)
        at com.itangcent.idea.plugin.api.export.AbstractRequestClassExporter.access$exportMethodApi(AbstractRequestClassExporter.kt:32)
        at com.itangcent.idea.plugin.api.export.AbstractRequestClassExporter$export$1.invoke(AbstractRequestClassExporter.kt:114)
        at com.itangcent.idea.plugin.api.export.AbstractRequestClassExporter$export$1.invoke(AbstractRequestClassExporter.kt:32)
        at com.itangcent.idea.plugin.api.export.AbstractRequestClassExporter.foreachMethod(AbstractRequestClassExporter.kt:455)
        at com.itangcent.idea.plugin.api.export.AbstractRequestClassExporter.export(AbstractRequestClassExporter.kt:112)
        at com.itangcent.idea.plugin.api.export.ComboClassExporter$export$1.apply(ComboClassExporter.kt:38)
        at com.itangcent.idea.plugin.api.export.ComboClassExporter$export$1.apply(ComboClassExporter.kt:13)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
        at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
        at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
        at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:449)
        at com.itangcent.idea.plugin.api.export.ComboClassExporter.export(ComboClassExporter.kt:38)
        at com.itangcent.idea.plugin.api.export.yapi.YapiApiExporter$doExport$3.invoke(YapiApiExporter.kt:65)
        at com.itangcent.idea.plugin.api.export.yapi.YapiApiExporter$doExport$3.invoke(YapiApiExporter.kt:13)
        at com.itangcent.intellij.psi.SelectedHelper$Builder$onFile$1.invoke(SelectedHelper.kt:144)
        at com.itangcent.intellij.psi.SelectedHelper$Builder$onFile$1.invoke(SelectedHelper.kt:22)
        at com.itangcent.intellij.context.ActionContext$runInReadUI$1.run(ActionContext.kt:314)
        at com.intellij.openapi.application.ReadAction.lambda$run$1(ReadAction.java:53)
        at com.intellij.openapi.application.ReadAction$$Lambda$960/699603244.compute(Unknown Source)
        at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
        at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:57)
        at com.intellij.openapi.application.ReadAction.run(ReadAction.java:53)
        at com.itangcent.intellij.context.ActionContext.runInReadUI(ActionContext.kt:308)
        at com.itangcent.intellij.psi.SelectedHelper$Builder.onFile(SelectedHelper.kt:142)
        at com.itangcent.intellij.psi.SelectedHelper$Builder.access$onFile(SelectedHelper.kt:22)
        at com.itangcent.intellij.psi.SelectedHelper$Builder$traversal$2.invoke(SelectedHelper.kt:78)
        at com.itangcent.intellij.psi.SelectedHelper$Builder$traversal$2.invoke(SelectedHelper.kt:22)
        at com.itangcent.intellij.context.ActionContext$runInReadUI$1.run(ActionContext.kt:314)
        at com.intellij.openapi.application.ReadAction.lambda$run$1(ReadAction.java:53)
        at com.intellij.openapi.application.ReadAction$$Lambda$960/699603244.compute(Unknown Source)
        at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:936)
        at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:57)
        at com.intellij.openapi.application.ReadAction.run(ReadAction.java:53)
        at com.itangcent.intellij.context.ActionContext.runInReadUI(ActionContext.kt:308)
        at com.itangcent.intellij.psi.SelectedHelper$Builder.traversal(SelectedHelper.kt:72)
        at com.itangcent.idea.plugin.api.export.yapi.YapiApiExporter.doExport(YapiApiExporter.kt:73)
        at com.itangcent.idea.plugin.api.export.yapi.YapiApiExporter.export(YapiApiExporter.kt:18)
        at com.itangcent.idea.plugin.actions.YapiExportAction.actionPerformed(YapiExportAction.kt:40)
        at com.itangcent.intellij.actions.KotlinAnAction$actionPerformed$2.invoke(KotlinAnAction.kt:49)
        at com.itangcent.intellij.actions.KotlinAnAction$actionPerformed$2.invoke(KotlinAnAction.kt:17)
        at com.itangcent.intellij.context.ActionContext$runAsync$2.run(ActionContext.kt:169)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

对比验证,该情况和返回类型相关。export 正常的代码:

@RestController
@RequestMapping("/testJava")
public class TestJavaController {

    @GetMapping("/suc")
    public SucDTO suc() {
        return null;
    }

}

class SucDTO {
    private String field;

    public String getField() {
        return field;
    }

    public void setField(String field) {
        this.field = field;
    }
}

异常的代码:

@RestController
@RequestMapping("/test")
public class TestJavaController {

    @GetMapping("/failed")
    public FailedDTO failed() {
        return null;
    }

}

class FailedDTO {
    private SomeEnum field;

    public SomeEnum getField() {
        return field;
    }

    public void setField(SomeEnum field) {
        this.field = field;
    }
}

enum SomeEnum {
    ONE, TWO
}

初步判断是对 Enum 解析的问题。
自己搭建插件 debug 环境总是抛com.itangcent.intellij.extend.guice.InjectorsKt.withUnsafe相关异常,暂未进一步分析。

关于 kotlin Controller、Git Submodule 配置和推荐配置

插件版本:0.9.1.183.0.5
Intellij IDEA:2019.2 Build 192.5728.98

最近新发现的这个工具,谢谢作者~
使用的时候遇到几个困惑:

  1. 试了下 Kotlin 的 Controller 可以生成 API,但貌似读不到注释。
    接口分类和接口名都是 code,而不是来自注释
    接口备注也是空的
  2. 使用 GitSubmodule 组织的项目,在Intellij 中也是同样结构的 Module。.yapi.config 放在子模块或父模块的根目录生成的时候都提示 [TRACE] No config [.yapi.config] be found [TRACE] No config [.easy.api.config] be found 。(•_•)?
  3. 因为自定义配置无效,使用推荐的配置在 Java 的 Controller 中注释中的 @undone @public 并不能对应到 yapi 的未完成和开放接口?

start up idea error with installed from disk

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'plugins'
  2. Click on 'install'
  3. install yapi.jar from disk.
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots

image

Desktop (please complete the following information):

  • OS: [MacOs mojave]
  • Idea
  • Version [U 2019.2]
  • already installed easy-api plg jar

api.tag的使用疑问

use version

yapi version:1.8.5
easy-yapi version:easy-yapi.1.2.1.183.0.4

image
我看到配置示例是这样配置的

#yapi tag
api.tag=groovy:it.hasDoc("public")?"public":null

处理这个tag的写法的在接口上增加@public注解

我也照着写法写了一个

#yapi tag
api.tag=groovy:it.hasDoc("201911")?"201911":null

导出到yapi后,在yapi界面上无法按照tag进行filter
image

注释的tag是没创建在yapi标签库里的吗?

error to export to yapi when delete api on yapi-server

Describe the bug
export data errro

To Reproduce
Steps to reproduce the behavior:
选中我已更新的接口目录,导出到yapi。

Expected behavior
成功导入

Screenshots

[INFO] No config [.yapi.config] be found
[INFO] No config [.easy.api.config] be found
[INFO] Start find apis...
[INFO] Add new cart:http://yapi-web.yapi.10.76.95.124.xip.io/project/21/interface/api/cat_33
[ERROR] error to cache api info,com.intellij.openapi.project.IndexNotReadyException: Please change caller according to com.intellij.openapi.project.IndexNotReadyException documentation
at com.intellij.openapi.project.IndexNotReadyException.create(IndexNotReadyException.java:77)
at com.intellij.util.indexing.FileBasedIndexImpl.handleDumbMode(FileBasedIndexImpl.java:777)
at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:726)
at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:709)
at com.intellij.psi.stubs.StubIndexImpl.doProcessStubs(StubIndexImpl.java:305)
at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:281)
at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:121)
at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:109)
at com.intellij.psi.impl.java.stubs.index.JavaFullClassNameIndex.get(JavaFullClassNameIndex.java:47)
at com.intellij.psi.impl.file.impl.JavaFileManagerImpl.doFindClasses(JavaFileManagerImpl.java:88)
at com.intellij.psi.impl.file.impl.JavaFileManagerImpl.findClass(JavaFileManagerImpl.java:123)
at com.intellij.psi.impl.PsiElementFinderImpl.findClass(PsiElementFinderImpl.java:38)
at com.intellij.psi.impl.JavaPsiFacadeImpl.doFindClass(JavaPsiFacadeImpl.java:116)
at com.intellij.psi.impl.JavaPsiFacadeImpl.findClass(JavaPsiFacadeImpl.java:93)
at com.siyeh.ig.psiutils.ClassUtils.findClass(ClassUtils.java:99)
at com.itangcent.intellij.psi.PsiClassUtils.findMethodFromFullName(PsiClassUtils.kt:37)
at com.itangcent.idea.plugin.api.cache.CachedClassExporter.readApiFromCache(CachedClassExporter.kt:154)
at com.itangcent.idea.plugin.api.cache.CachedClassExporter.access$readApiFromCache(CachedClassExporter.kt:22)
at com.itangcent.idea.plugin.api.cache.CachedClassExporter$export$1$1.invoke(CachedClassExporter.kt:88)
at com.itangcent.idea.plugin.api.cache.CachedClassExporter$export$1$1.invoke(CachedClassExporter.kt:22)
at com.itangcent.intellij.context.ActionContext$runInReadUI$1.run(ActionContext.kt:271)
at com.intellij.openapi.application.ReadAction.lambda$run$1(ReadAction.java:53)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:974)
at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:57)
at com.intellij.openapi.application.ReadAction.run(ReadAction.java:53)
at com.itangcent.intellij.context.ActionContext.runInReadUI(ActionContext.kt:268)
at com.itangcent.idea.plugin.api.cache.CachedClassExporter$export$1.invoke(CachedClassExporter.kt:86)
at com.itangcent.idea.plugin.api.cache.CachedClassExporter$export$1.invoke(CachedClassExporter.kt:22)
at com.itangcent.intellij.context.ActionContext$runAsync$2.run(ActionContext.kt:158)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

[INFO] search api from:com.xxx.xyz.admin.controller.UserController
[INFO] Add new cart:http://yapi-web.yapi.10.76.95.124.xip.io/project/21/interface/api/cat_34
[INFO] Add new cart:http://yapi-web.yapi.10.76.95.124.xip.io/project/21/interface/api/cat_35
[INFO] Add new cart:http://yapi-web.yapi.10.76.95.124.xip.io/project/21/interface/api/cat_36
[INFO] Add new cart:http://yapi-web.yapi.10.76.95.124.xip.io/project/21/interface/api/cat_37
[INFO] Apis exported completed

Process finished with exit code 0

Desktop (please complete the following information):

  • OS: [macos mojave]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context
我删除了某一个文件夹后(目的是之前的类的注释写的不好,删除的时候删错了,也就是说,删掉了一个我并没更新的接口目录。)
但是再次尝试就ok了,应该不是bug,只是日志输出?

getMapping 没有请求参数

get请求的接口上传 没有请求参数的类型, 有木有可能把 类型参数加载备注里哈 O(∩_∩)O哈哈~

resolve {@link } in @return

example:

    /**
     * 获取当前用户类型
     *
     * @return {@link com.itangcent.common.constant.UserType#getType()}
     */
    @GetMapping("/type")
    public Result<Integer> currUserType() {
        return Result.success(UserType.values()[new Random(System.currentTimeMillis()).nextInt(UserType.values().length)].getType());
    }


    /**
     * 获取所有用户类型
     *
     * @return {@link com.itangcent.common.constant.UserType#getType()}
     */
    @GetMapping("/types")
    public Result<List<Integer>> types() {
        final List<Integer> types = Stream.of(UserType.values()).map(UserType::getType).collect(Collectors.toList());
        return Result.success(types);
    }

默认配置无法替换

默认配置无法替换,例如我需要对过期接口进行标注tag,但是默认已经有了,但我想标注为中文结果出现两个。

//默认配置
api.tag[@java.lang.Deprecated]=deprecated
//配置文件中的配置
api.tag[@java.lang.Deprecated]=废弃

最终的结果就是出现了两个标签 deprecated 和 废弃

希望能替换默认配置

yapi旧版本当前插件不能兼容的问题

当前使用的yapi版本 1.4.x
我看你们根据token获取project信息的参数只传了token,但是旧版本yapi是必须传projectId的,请问这个有没有支持提供设置projectId的入口?

询问下json.rule.field.ignore的用法

Describe the bug

  • 看到配置规则有可以忽略某个字段的功能,
    image

现在是这么个情况 我是直接吧数据库实体返回到做http响应信息了,项目里使用了mybatis的一个框架(mybatis-plus) 它有个ar模式 特点是数据库的实体类要继承一个父类 数据库实体形式如:

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("banner_info")
public class BannerInfoEntity extends Model<BannerInfoEntity> {
}

继承的Model类的结构如下:

public abstract class Model<T extends Model<?>> implements Serializable {
    private static final long serialVersionUID = 1L;
    private transient Log log = LogFactory.getLog(this.getClass());
}

里面有个日志属性log 返回参数实体我不想被返回出去 里面还有一个serialVersionUIDeasy-yapi自动过滤了吧

我在.easy.api.config文件里配置了这样:
json.rule.field.ignore=com.baomidou.mybatisplus.extension.activerecord.Model#log
或者加个@符合在类路径前json.rule.field.ignore=@com.baomidou.mybatisplus.extension.activerecord.Model#log
貌似都没起作用 询问下json.rule.field.ignore的用法具体是怎么用的 我在demo里没看到这个的配置事例🙏

如何添加多个请求头

通过增加配置文件可以进行自定义配置,添加了method.additional.header配置可以添加请求头,但是我这边会要求前对传入多个请求头,如token,客户端信息、请求参数验签等,但是发现该配置(method.additional.header)只能添加一条请求头,请问一下如何添加多个请求头信息呢?

接口方法上有自定义注解的参数 如何过滤掉 不作为接口的参数出现在文档中

哈哈 大佬 我又来了 🙏

软件版本:

IDEA:2019.2.4
yapi:easy-yapi.1.2.1.183.0.4.jar

情况描述

我在项目里对于用户信息的提取与装配使用了实现HandlerMethodArgumentResolver做了个参数解析器,在接口上标注了特定注解的时候触发 如下:

  • 参数解析器
/**
 * 登录用户信息处理Resolver
 *
 * @author qinkangdeid
 * @date 2019-10-29
 */
public class LoginUserArgumentResolver implements HandlerMethodArgumentResolver {


    @Override
    public boolean supportsParameter(MethodParameter parameter) {
// 这里断言成功执行resolveArgument
 boolean hasUserContextAnoo = parameter.hasParameterAnnotation(UserContext.class);
        return hasUserContextAnoo;
    }

    @Override
    public UserContent resolveArgument(MethodParameter parameter, ModelAndViewContainer container, NativeWebRequest request, WebDataBinderFactory factory) {
// 具体装配逻辑
        return new UserContent(1);
    }
}
  • 标记注解
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface UserContext {

}
  • 接口写法就是这样的
    /**
     * 忽略自定义注解参数
     * //     * @param userDtoWithEnum 用户Dto与枚举
     *
//     * @param userContent 用户内容(并不想让他出现在文档请求参数中)
     * @return {@link com.itangcent.common.dto.IResult}
     */
    @PostMapping("")
    public IResult testParamsWithCustomAnno(@UserContext UserContent userContent) {
        return Result.success("ok");
    }

那么其实 我的接口对前端来说是没有参数的 所以我想把带有@UserContext 注解的参数过滤掉
我像之前忽略返回响应的写法配置了 好像没生效

# 过滤接口自定义参数
json.rule.field.ignore=groovy:it.type().name()=="com.itangcent.springboot.demo.UserContent"

json.rule.field.ignore=groovy:it.hasAnn("com.itangcent.springboot.demo.UserContext")

它还是会把接口上UserContent的内容提取出来
image
应该怎样配置这个接口请求参数的忽略设定?
我发了一个pull request 里面有实例代码 在spring-demo上

可能还有另外一个问题 使用jwt对接口做鉴权返回得到一个token 把token放请求header里 类似于上面的操作 额外在另外的地方对token做解析 那么header的值也是不会写在接口方法上使用@RequestHeader,但是确实要请求接口时要header带上token 这个情况

SpringBoot export api to Yapi server with @RequestMapping("adv“)

Describe the bug
SpringBoot export api to Yapi server with @RequestMapping("adv“)

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
auto fill '/' to path.

Screenshots
error log:
search api from:com.pengshu.thanos.admin.controller.AdvCustomerController
[INFO] Post failed:path第一位必需为 /, 只允许由 字母数字-/_:.! 组成

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context

Invalid Token

在获取项目信息的时候需要传入id参数,YApi的文档中没有写,但是实际调用需要传入项目id。导致出现Invalid Token

Yapi Dashboard

Dashboard:

project api yapi▽
ModuleA ProjectA
  |─ClassA   |─ CartA
    |─apiA   |─ CartB
    |─apiB     |─apiA
  |─ClassB ...

Action:

  • load async
  • drag api from project api panel to yapi project/cart

参数字段排序问题

能否支持按参数的字段顺序生成yapi参数表格。
我有一个接口的参数有点多,前端是划分了三个区域的,代码是原型的先后写的字段,但是生成的yapi接口文档中参数的顺序就是乱的,很难查找,希望能有办法对参数进行排序

最近使用出现class handle error

最近更新的很频繁 用的最新版本
刚刚使用了下 包这个错 然后IDEA卡死 只能强制停止进程了

image

我自定义的config没有什么东西 如下:

# 过滤接口自定义参数
param.ignore=@com.baibu.platform.weapp.zhijing.offers.core.user.UserContent

# 额外要求header中携带token
method.additional.header[!@com.baibu.platform.weapp.zhijing.offers.core.user.PublicMethod]={name: "Token",value: "",desc: "登陆获取到的Token",required:true, example:"eyJhbGciO"}

可以自定义处理的注解吗?

可以自定义处理的注解吗?我们的项目没有使用Spring的那些注解,但是大体表现形式上是一样,这样的我要怎么扩展一下呢?

无法读取配置文件和@mouble 注解没用

您好,非常感谢您开发了这么好用的插件。但是我有一点小疑问。

  1. 我已经配了
module=#module

#忽略不解析
ignore=#ignore

#额外的json解析规则
#支持jackson注解
json.rule.field.name=@com.fasterxml.jackson.annotation.JsonProperty#value
#ObjectId和Date处理为String
json.rule.convert[org.bson.types.ObjectId]=java.lang.String
json.rule.convert[java.util.Date]=java.lang.String

且 日志已经有了

[TRACE]	find config file:D:\git\wakanda\wakanda-home\src\main\java\com\ideacome\wakanda\home\controller\permission/.easy.api.config

我的java代码:

/**
 * 账号管理1 #moulde 父类啊
 *
 * @module 父类
 * @author 罗成
 */
@RestController
@RequestMapping("permission/user")
public class UserController {

但是 实际上 去yapi里面看:
image
并没有创建父类接口
2. 我在
image

很多地方加了配置,只有在java文件所在的目录配置才能生效,根目录配置无法读取到。麻烦作者大大看到了帮忙解决下

希望增加@RequestParam 和 @PathVariable 使用到枚举作为参数的支持注释的解析

Is your feature request related to a problem? Please describe.
@RequestParam@PathVariable (这种情况很少) 注解的枚举参数 没能把 枚举 枚举备注 解释在其他信息里面
我的项目大量使用了枚举做参数 类似下面:

/**
     * 测试枚举作为表单参数RequestParam
     *
     * @param enumVal 枚举值:ONE:一 TWO:二  {@link TestEnum}
     * @return com.baibu.framework2.net.DataResponse<com.baibu.order.web.controller.order.baibu.TestBean>
     */
    @PostMapping("getByEnum")
    public DataResponse<TestBean> getByEnumRequestParam(@RequestParam TestEnum enumVal) {
        return DataResponse.ok(new TestBean());
    }


    /**
     * 测试枚举作为路径参数
     *
     * @param enumVal 枚举值:ONE:一 TWO:二   {@link TestEnum}
     * @return com.baibu.framework2.net.DataResponse<com.baibu.order.web.controller.order.baibu.TestBean>
     */
    @PostMapping("{enumVal}}")
    public DataResponse<TestBean> getByEnumPathVariable(@PathVariable TestEnum enumVal) {
        return DataResponse.ok(new TestBean());
    }

Describe the solution you'd like
希望可以像 对于 @requestbody 注解的参数对象含有枚举可以解析了 把枚举属性的注释都列出来 放在其他信息里面

image

Describe alternatives you've considered

Additional context

Use JsonReader.setLenient(true) to accept malformed JSON at line 4 column 12 path

` com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 4 column 12 path $
at com.google.gson.JsonParser.parse(JsonParser.java:65)
at com.google.gson.JsonParser.parse(JsonParser.java:45)
at com.itangcent.common.utils.GsonUtils.parseToJsonTree(GsonUtils.kt:51)
at com.itangcent.idea.plugin.api.export.yapi.AbstractYapiApiHelper.getProjectInfo(AbstractYapiApiHelper.kt:119)
at com.itangcent.idea.plugin.api.export.yapi.AbstractYapiApiHelper.getProjectIdByToken(AbstractYapiApiHelper.kt:91)
at com.itangcent.idea.plugin.api.export.yapi.YapiCachedApiHelper.getProjectIdByToken(YapiCachedApiHelper.kt:34)
at com.itangcent.idea.plugin.api.export.yapi.YapiApiHelper.findCat(YapiApiHelper.kt:40)
at com.itangcent.idea.plugin.api.export.yapi.AbstractYapiApiExporter.getCartForCls(AbstractYapiApiExporter.kt:95)
at com.itangcent.idea.plugin.api.export.yapi.AbstractYapiApiExporter.getCartForCls(AbstractYapiApiExporter.kt:63)
at com.itangcent.idea.plugin.api.export.suv.SuvApiExporter$YapiApiExporterAdapter$SuvYapiApiExporter.getCartForCls(SuvApiExporter.kt:535)
at com.itangcent.idea.plugin.api.export.yapi.AbstractYapiApiExporter.exportDoc(AbstractYapiApiExporter.kt:120)
at com.itangcent.idea.plugin.api.export.suv.SuvApiExporter$YapiApiExporterAdapter.doExportDocs(SuvApiExporter.kt:514)
at com.itangcent.idea.plugin.api.export.suv.SuvApiExporter$ApiExporterAdapter$doExportApisFromMethod$2.invoke(SuvApiExporter.kt:335)
at com.itangcent.idea.plugin.api.export.suv.SuvApiExporter$ApiExporterAdapter$doExportApisFromMethod$2.invoke(SuvApiExporter.kt:166)
at com.itangcent.intellij.context.ActionContext$runAsync$2.run(ActionContext.kt:173)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 4 column 12 path $
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1568)
at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1409)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:542)
at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
at com.google.gson.JsonParser.parse(JsonParser.java:60)
... 19 more

上传api时候报错` @tangcent

上传API报错

config中配置了:
java.to.js.type=(function(type){type = type.replace("ja:va.lang.","");return type.replace(type[0],type[0].toLowerCase());})
doc.param=js:"\n类型:"+${java.to.js.type}(it.type().name());

上传API时:
[ERROR] unsupported script type:JavaScript,script:"类型:"+it.type().name();
[ERROR] unsupported script type:JavaScript,script:"类型:"+it.type().name();
[ERROR] unsupported script type:JavaScript,script:"类型:"+it.type().name();
[ERROR] unsupported script type:JavaScript,script:"类型:"+it.type().name();

以前上传没问题的, 现在上传带不了参数类型了...

我昨天升级了 IDEA 2019.3.2 和最新easyyapi插件 , 后就出现了这样的问题~~

小白求问,返回值为啥获取有问题...

//登录成功 Map<String, Object> mapData = new HashMap<>(); mapData.put("LOGINTOKEN", uuid); mapData.put("user", getUserFromRedis(uuid)); return ResultUtil.success(mapData);
这个能正常解析出来为 map,里面一个user 一个 token
List<Province> list = provinceRepository.findAll(); return ResultUtil.success(list);
这个正常返回应该是list,里面包含 A 类,但是解析出来就是 B类了...

是否支持Json字段由驼峰变为下划线

描述
由于Jackson使用了全局配置FEATURE_PROPERTIES_NAMING_STRATEGY=SNAKE_CASE,所以RequestBodyResponseBody在序列化为Json时,都会相应的由驼峰转为下划线。

我查询了EasyYApi的配置文档,没有找到如何能满足我需求(由驼峰转为下划线)的方法。

请帮忙下,谢谢!

JDK8的时间类型未解析成常规格式

Describe the bug

JDK8的时间类型解析出来成了下面样式
image
image

Expected behavior
希望可以解析成常规的时间字符串 例如:

  • LocalDateTime ---> 2019-10-22 14:01:01
  • LocalDate ---> 2019-10-22

返回结构上传到yapi失败

Describe the bug
为啥我自定义的通用返回对象在yapi中无法显示,难道一定要用你demo里的result对象吗

image
image

image

是否考虑做接口项目的全局配置例如全局统一header全局统一api前缀

是否支持 全局设置header值? 这样理解:一个header里的值(例如token) 是所有需要鉴权的接口的隐藏参数 只是在接口上是不放@RequestHeader 不写出来 这个header值是在参数传递解析阶段判断是否存在的 类似的
com.itangcent.springboot.demo.LoginUserArgumentResolver#resolveArgument 去校验

  /**
     * 所有需鉴权统一校验鉴权header值
     *
     * @param parameter 参数
     * @param container 容器
     * @param request   请求
     * @param factory   factory
     * @return {@link com.itangcent.springboot.demo.UserContent}
     */
    @Override
    public UserContent resolveArgument(MethodParameter parameter, ModelAndViewContainer container, NativeWebRequest request, WebDataBinderFactory factory) {
        // 在Resolver进行必传header的校验 或 在拦截器校验 这种情况在接口上是不放@RequestHeader的
        // 等于是header里的token是所有需要鉴权的接口的隐藏参数
        String token = request.getHeader("Token");
        if (StringUtils.isEmpty(token)) {
            throw new RuntimeException("token is empty! you should set the token in the http header");
        }
        // 组装UserContent UseCache.getByToken(token)
        return new UserContent(1);
    }

这个是否可以放在配置里,类似:

# 全局请求配置
global.config.headers=[{"headerName1":"headerComment1","headerName2":"headerComment2"}]

创建接口到yapi时增加上这个隐藏参数?emm.... 不过获取鉴权的接口 也会被加上了token

mvc 还有一个 context-path设置接口统一前缀的 在application.yml设置

server:
  servlet:
    context-path: /api-prefix

配置后所有接口的都会带上这个前缀 /api-prefix 类似controller的接口写的是/users/info,整个请求url就会变成/api-prefix/users/info 能配成全局配置的话加更好了
#76 最后表述

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.