Skip to content

Commit

Permalink
Merge pull request #69 from tangcent/release/stable
Browse files Browse the repository at this point in the history
release v1.1.1.183.0.4
  • Loading branch information
tangcent authored Oct 28, 2019
2 parents 1d6f610 + b979fa3 commit 51f735c
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 99 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

- [demo](https://github.com/Earth-1610/spring-demo)

- [QA](https://github.com/tangcent/easy-yapi/blob/master/docs/QA.md)

# Table of Contents

* 1 [Feature](#Feature)
Expand Down
2 changes: 2 additions & 0 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

- [demo](https://github.com/Earth-1610/spring-demo)

- [QA](https://github.com/tangcent/easy-yapi/blob/master/docs/QA.md)

-[easy-api](https://github.com/tangcent/easy-api)的基础上增加对yapi的支持

如果你对easy-api有兴趣或者希望支持其他第三方API管理平台,那么这也是一个很好的例子,通过对比[easy-api](https://github.com/tangcent/easy-api)[easy-yapi](https://github.com/tangcent/easy-aypi)的差异,可以了解到如何在
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group 'com.itangcent'
version '1.1.0.183.0.2'
version '1.1.1.183.0.4'

165 changes: 165 additions & 0 deletions docs/QA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
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");
}
}

```
75 changes: 0 additions & 75 deletions docs/en/2. Supported-custom-rules.md

This file was deleted.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.daemon=true
org.gradle.workers.max=8
idea_version=2017.3.5
plugin_name=EasyYapi
plugin_version=1.1.0.183.0.2
plugin_version=1.1.1.183.0.4

descriptionFile=parts/pluginDescription.html
changesFile=parts/pluginChanges.html
Binary file modified idea-plugin/libs/intellij-jvm.jar
Binary file not shown.
19 changes: 5 additions & 14 deletions idea-plugin/parts/pluginChanges.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
<a href="https://github.com/tangcent/easy-yapi/releases/tag/v1.1.0.2">v1.1.0.183.0.2(2019-10-23)</a>
<a href="https://github.com/tangcent/easy-yapi/releases/tag/v1.1.1.4">v1.1.1.183.0.4(2019-10-28)</a>
<br/>
<a href="https://github.com/tangcent/easy-yapi/blob/master/IDEA_CHANGELOG.md">Full Changelog</a>
<ul>enhancement:
<li>support rule: name[filter]=value<a
href="https://github.com/tangcent/easy-api/pull/138">(#138)</a>
</li>
<li>parse kotlin files in ApiDashboard<a
href="https://github.com/tangcent/easy-api/pull/141">(#141)</a>
<li>provide 'hasModifier(modifier)' for class/method/field<a
href="https://github.com/tangcent/easy-api/issues/157">(#157)</a>
</li>
</ul>
<ul>fix:
<li>support Serializer for Enum<a
href="https://github.com/tangcent/easy-api/issues/134">(#134)</a>
</li>
<li>fix error base path for APIs in super class<a
href="https://github.com/tangcent/easy-api/issues/137">(#137)</a>
</li>
<li>fix: ApiDashboard not show kotlin module&apis<a
href="https://github.com/tangcent/easy-api/issues/140">(#140)</a>
<li>script config: class.name()<a
href="https://github.com/tangcent/easy-api/issues/155">(#155)</a>
</li>
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class RecommendConfigReader : ConfigReader {
[email protected]#value
[email protected]#serialize
#ignore transient field
json.rule.field.ignore=groovy:it.hasModifier("transient")
#The ObjectId and Date are parsed as strings
json.rule.convert[org.bson.types.ObjectId]=java.lang.String
json.rule.convert[java.util.Date]=java.lang.String
Expand Down
Loading

0 comments on commit 51f735c

Please sign in to comment.