-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test verifying partial template works; Extract accessAwareFieldVa…
…lueResolver; Add test verifying priority fo values extracted from object
- Loading branch information
1 parent
76d3964
commit 998cdeb
Showing
4 changed files
with
108 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...in/java/org/openapitools/codegen/templating/handlebars/AccessAwareFieldValueResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.openapitools.codegen.templating.handlebars; | ||
|
||
import com.github.jknack.handlebars.context.FieldValueResolver; | ||
|
||
import java.lang.reflect.AccessibleObject; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
// $ref: https://github.com/jknack/handlebars.java/issues/917 | ||
public class AccessAwareFieldValueResolver extends FieldValueResolver { | ||
|
||
public static final AccessAwareFieldValueResolver INSTANCE = new AccessAwareFieldValueResolver(); | ||
|
||
@Override | ||
protected Set<FieldValueResolver.FieldWrapper> members(Class<?> clazz) { | ||
var members = super.members(clazz); | ||
return members.stream() | ||
.filter(this::isValidField) | ||
.collect(Collectors.toSet()); | ||
} | ||
|
||
boolean isValidField(FieldWrapper fw) { | ||
if (fw instanceof AccessibleObject) { | ||
return isUseSetAccessible(fw); | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters