diff --git a/build.gradle b/build.gradle index 390427568..4530359ca 100644 --- a/build.gradle +++ b/build.gradle @@ -1,2 +1,2 @@ group 'com.itangcent' -version '1.7.0.0.183.0' \ No newline at end of file +version '1.8.0.0.183.0' \ No newline at end of file diff --git a/docs/QA.md b/docs/QA.md deleted file mode 100644 index 9ff815295..000000000 --- a/docs/QA.md +++ /dev/null @@ -1,205 +0,0 @@ -1. How to add custom config? - - * add .easy.api.config in the root of project or module - - * see [Supported-custom-rules.md](https://github.com/tangcent/easy-api/blob/master/docs/2.%20Supported-custom-rules.md) - -2. How to group apis to special directory? - - * add config: - ```properties - #find module for comment tag - module=#module - ``` - - * add comment tag at class - ```java - /** - * Mock Apis - * - * @module mock - */ - @RestController - @RequestMapping(value = "mock") - public class MockCtrl { - } - ``` - -3. How to ignore apis? - - * add config: - ```properties - #ignore class or method which has comment tag 'ignore' - ignore=#ignore - ``` - - * add comment tag at controller class for ignore all apis in controller - ```java - /** - * Mock Apis - * - * @ignore - */ - @RestController - @RequestMapping(value = "mock") - public class MockCtrl { - } - ``` - - * add comment tag at api for ignore special api in controller - ```java - /** - * Mock Apis - */ - @RestController - @RequestMapping(value = "mock") - public class MockCtrl { - - /** - * Mock String - * @ignore - */ - @GetMapping("/string") - public String mockString() { - return Result.success("mock string"); - } - - } - ``` - -4. How to set name&description of api/directory? - - * in general: - ```java - /** - * The head line will be the name of api directory - * The rest lines will be the description of api directory - */ - @RestController - @RequestMapping(value = "mock") - public class MockCtrl { - - /** - * The head line will be the name of api - * The rest lines will be the description of api - */ - @GetMapping("/string") - public String mockString() { - return Result.success("mock string"); - } - } - ``` - -5. How to mark api as deprecated in description - - * you can add additional config: - ```properties - doc.method[#deprecated]=groovy:"\n「deprecated」" + it.doc("deprecated") - doc.method[@java.lang.Deprecated]=「deprecated」 - doc.method[@kotlin.Deprecated]=groovy:"\n「deprecated」" + it.ann("kotlin.Deprecated","message") - - doc.method[groovy:it.containingClass().hasDoc("deprecated")]=groovy:"\n「deprecated」" + it.containingClass().doc("deprecated") - doc.method[groovy:it.containingClass().hasAnn("java.lang.Deprecated")]=「deprecated」 - doc.method[groovy:it.containingClass().hasAnn("kotlin.Deprecated")]=groovy:"\n「deprecated」 " + it.containingClass().ann("kotlin.Deprecated","message") - - ``` - -6. How to declare a api requires some special permission in a description with javax.annotation.security? - - * add config for spring security: - ```properties - # security description - doc.method[@javax.annotation.security.RolesAllowed]=groovy:"require role:"+it.ann("javax.annotation.security.RolesAllowed") - ``` - - * code: - ```java - /** - * The head line will be the name of api directory - * The rest lines will be the description of api directory - */ - @RestController - @RequestMapping(value = "mock") - public class MockCtrl { - - /** - * The head line will be the name of api - * The rest lines will be the description of api - */ - @GetMapping("/string") - @RolesAllowed("admin") - public String mockString() { - return Result.success("mock string"); - } - } - - ``` - -7. How to config for spring security - - * add config for spring security: - ```properties - # security description - find_role_in_PreAuthorize=(function(exp){var str="";if(exp.indexOf("hasRole")!=-1){var roles=exp.match(/hasRole\\((.*?)\\)/);if(roles&&roles.length>1){str+="require role:"+roles[1];}};return str}) - doc.method[@org.springframework.security.access.prepost.PreAuthorize]=js:${find_role_in_PreAuthorize}(it.ann("org.springframework.security.access.prepost.PreAuthorize")) - ``` - - * code: - ```java - /** - * The head line will be the name of api directory - * The rest lines will be the description of api directory - */ - @RestController - @RequestMapping(value = "mock") - public class MockCtrl { - - /** - * The head line will be the name of api - * The rest lines will be the description of api - */ - @GetMapping("/string") - @PreAuthorize("hasRole('admin')") - public String mockString() { - return Result.success("mock string"); - } - } - - ``` - -8. How to ignore the special field? - - * To ignore the field with special name: - ```properties - # ignore field 'log' - json.rule.field.ignore=log - ``` - - * To ignore the field with special type: - ```properties - # ignore field 'log' typed xxx.xxx.Log - json.rule.field.ignore=groovy:it.type().name()=="xxx.xxx.Log" - ``` - - * To ignore the field with special modifier: - ```properties - #ignore transient field - json.rule.field.ignore=groovy:it.hasModifier("transient") - ``` - -9. How to resolve the special type as another one? - - * Receive or output 'java.time.LocalDateTime' as 'yyyy-mm-dd' - ```properties - #Resolve 'java.time.LocalDateTime' as 'java.lang.String' - json.rule.convert[java.time.LocalDateTime]=java.lang.String - json.rule.convert[java.time.LocalDate]=java.lang.String - ``` - - * Receive or output 'java.time.LocalDateTime' as timestamp - ```properties - #Resolve 'java.time.LocalDateTime' as 'java.lang.Long' - json.rule.convert[java.time.LocalDateTime]=java.lang.Long - json.rule.convert[java.time.LocalDate]=java.lang.Long - ``` - diff --git a/docs/en/1. Config.md b/docs/en/1. Config.md deleted file mode 100644 index d700963fb..000000000 --- a/docs/en/1. Config.md +++ /dev/null @@ -1,61 +0,0 @@ -# Setting In IDE - -- Preferences(Settings) > Other Settings > EasyApi - -*** - -# Local config file - -## First step -- add the config file in the root of project/module - -| file | type | scope | -| ------------ | ------------ | ------------ | -| .easy.api.config | property | markdown/postman | -| .easy.api.yml/.easy.api.yaml | yml | markdown/postman | -| .postman.config | property | postman | -| .postman.yml/.postman.yaml | yml | postman | - - - -## How to set rules? - [custom rules](https://github.com/tangcent/easy-api/blob/master/docs/2.%20Supported-custom-rules.md) - -## simple example - -### Module -set rule of module to tell plugin how to group api
-e.g.
-simple rule: -```text -module=#module -``` -js rule: -```text -module=js:it.doc("module") -``` -the plugin will try to read @module from comment of class like this -```text -/** - * @module awesome_module - */ -``` - -### Ignore -set rule of method to tell plugin not export it
-e.g.
-simple rule: -```text -ignore=#ignore -``` -js rule: -```text -ignore=js:it.hasDoc("ignore") -``` -the plugin will ignore methods that comment by @ignore like this: -```text -/** - * some comment of method(api) - * @ignore - */ -``` diff --git a/docs/en/3. Support-local-groovy-extension.md b/docs/en/3. Support-local-groovy-extension.md deleted file mode 100644 index 4fbdb338b..000000000 --- a/docs/en/3. Support-local-groovy-extension.md +++ /dev/null @@ -1,59 +0,0 @@ -- Add groovy file at $project/.easyapi/ext -- Named ${ActionName}Ext.groovy -- Supported actions: - - ApiCallAction - - ApiDashBoardAction - - FieldsToJsonAction - - MarkdownExportAction - - PostmanExportAction - -- Inject custom class by binder in `init` method - -- [demo](https://github.com/tangcent/spring-demo/blob/master/.easyapi/ext/) - -```groovy -import com.intellij.psi.* -import com.itangcent.common.model.Request -import com.itangcent.idea.plugin.api.export.ClassExporter -import com.itangcent.idea.plugin.api.export.SpringRequestClassExporter -import com.itangcent.idea.plugin.api.export.yapi.YapiClassExportRuleKeys -import com.itangcent.idea.plugin.api.export.yapi.YapiRequestKitKt -import com.itangcent.idea.plugin.script.ActionExt -import com.itangcent.idea.plugin.utils.KtHelper -import com.itangcent.intellij.context.ActionContext - -import java.util.stream.Collectors -import java.util.stream.Stream - -class YapiExportActionExt implements ActionExt { - - void init(ActionContext.ActionContextBuilder builder) { - - builder.bind(ClassExporter.class, KtHelper.INSTANCE.ktFunction({ - it.to(CustomClassExporter.class).in(com.google.inject.Singleton.class) - return null - })) - - } - - static class CustomClassExporter extends SpringRequestClassExporter { - - void processCompleted(PsiMethod method, Request request) { - super.processCompleted(method, request) - - String tags = ruleComputer.computer(YapiClassExportRuleKeys.TAG, method) - if (tags != null && !tags.isEmpty()) { - YapiRequestKitKt.setTags(request, Stream.of(tags.split("\n")) - .map { it.trim() } - .filter { !it.isEmpty() } - .collect(Collectors.toList()) - ) - } - - String status = ruleComputer.computer(YapiClassExportRuleKeys.STATUS, method) - logger.info(YapiRequestKitKt.class.toString()) - YapiRequestKitKt.setStatus(request, status) - } - } -} -``` \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 338595dc6..ea6fd8588 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.daemon=true org.gradle.workers.max=8 idea_version=2017.3.5 plugin_name=EasyYapi -plugin_version=1.7.0.0.183.0 +plugin_version=1.8.0.0.183.0 descriptionFile=parts/pluginDescription.html changesFile=parts/pluginChanges.html \ No newline at end of file diff --git a/idea-plugin/parts/pluginChanges.html b/idea-plugin/parts/pluginChanges.html index 676fc2f0e..819028b71 100644 --- a/idea-plugin/parts/pluginChanges.html +++ b/idea-plugin/parts/pluginChanges.html @@ -1,14 +1,14 @@ -v1.7.0.0.183.0(2020-02-27) +v1.8.0.0.183.0(2020-03-11)
Full Changelog \ No newline at end of file diff --git a/idea-plugin/src/main/resources/META-INF/plugin.xml b/idea-plugin/src/main/resources/META-INF/plugin.xml index c87152570..95de78585 100755 --- a/idea-plugin/src/main/resources/META-INF/plugin.xml +++ b/idea-plugin/src/main/resources/META-INF/plugin.xml @@ -1,7 +1,7 @@ com.itangcent.idea.plugin.easy-yapi EasyYapi - 1.7.0.0.183.0 + 1.8.0.0.183.0 Tangcent