Skip to content

Commit beb763a

Browse files
committed
OpenAPI: return types for Kotlin
1 parent ce5e22f commit beb763a

File tree

8 files changed

+548
-127
lines changed

8 files changed

+548
-127
lines changed

modules/jooby-openapi/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
117117
<sourceDir>${project.basedir}/src/main/java</sourceDir>
118118
</sourceDirs>
119+
<jvmTarget>1.8</jvmTarget>
119120
</configuration>
120121
</execution>
121122
<execution>

modules/jooby-openapi/src/main/java/io/jooby/internal/openapi/ExecutionContext.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ public ClassNode classNode(Type type) {
4848
return nodes.computeIfAbsent(type, this::newClassNode);
4949
}
5050

51+
public ClassNode classNodeOrNull(Type type) {
52+
try {
53+
return nodes.computeIfAbsent(type, this::newClassNode);
54+
} catch (Exception x) {
55+
return null;
56+
}
57+
}
58+
5159
private ClassNode newClassNode(Type type) {
5260
ClassReader reader = new ClassReader(source.byteCode(type.getClassName()));
5361
if (debug.contains(DebugOption.CLASS)) {

modules/jooby-openapi/src/main/java/io/jooby/internal/openapi/InsnSupport.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ public static <N extends AbstractInsnNode> Predicate<N> varInsn(int opcode, int
4848
return n -> n.getOpcode() == opcode && ((VarInsnNode) n).var == var;
4949
}
5050

51+
public static Iterator<AbstractInsnNode> prevIterator(AbstractInsnNode node) {
52+
return new NodeIterator(node, AbstractInsnNode::getPrevious);
53+
}
54+
5155
public static Stream<AbstractInsnNode> prev(AbstractInsnNode node) {
52-
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(new NodeIterator(node,
53-
AbstractInsnNode::getPrevious), Spliterator.ORDERED), false);
56+
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(prevIterator(node), Spliterator.ORDERED), false);
5457
}
5558

5659
public static Stream<AbstractInsnNode> next(AbstractInsnNode node) {

0 commit comments

Comments
 (0)