Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #https://github.com/smart-doc-group/smart-doc/issues/509 #513

Merged
merged 1 commit into from
May 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## smart-doc版本

### 版本号:2.7.0

- 更新日期: 2023-06-0x
- 更新内容:
1. 支持在子类使用@JsonIgnore忽略后,同时忽略父类中的同名字段,[#509](https://github.com/smart-doc-group/smart-doc/issues/509)
2. 修复内部类嵌套结构formdata example错误。[pr#512](https://github.com/smart-doc-group/smart-doc/pull/512)

### 版本号:2.6.9

- 更新日期: 2023-05-14
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/com/power/doc/utils/JavaClassUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,6 @@ private static List<DocJavaField> getFields(JavaClass cls1, int counter, Map<Str
}
if (!cls1.isInterface()) {
for (JavaField javaField : cls1.getFields()) {
long count = javaField.getAnnotations().stream()
.filter(annotation -> DocAnnotationConstants.SHORT_JSON_IGNORE.equals(
annotation.getType().getSimpleName()))
.count();
if (count > 0) {
continue;
}
String fieldName = javaField.getName();
String subTypeName = javaField.getType().getFullyQualifiedName();

Expand All @@ -225,6 +218,15 @@ private static List<DocJavaField> getFields(JavaClass cls1, int counter, Map<Str
if (fieldName.startsWith("is") && ("boolean".equals(subTypeName))) {
fieldName = StringUtil.firstToLowerCase(fieldName.substring(2));
}
long count = javaField.getAnnotations().stream()
.filter(annotation -> DocAnnotationConstants.SHORT_JSON_IGNORE.equals(annotation.getType().getSimpleName()))
.count();
if (count > 0) {
if (addedFields.containsKey(fieldName)) {
addedFields.remove(fieldName);
}
continue;
}

DocJavaField docJavaField = DocJavaField.builder();
boolean typeChecked = false;
Expand Down