Skip to content

Commit 2dfdabd

Browse files
committed
open-api: script javadoc
- WIP for lambda-ref javadoc parsing
1 parent 2f710ec commit 2dfdabd

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

modules/jooby-openapi/src/test/java/javadoc/JavaDocParserTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121

2222
public class JavaDocParserTest {
2323

24+
@Test
25+
public void lambdaDoc() throws Exception {
26+
withDoc(
27+
javadoc.input.LambdaRefApp.class,
28+
doc -> {
29+
System.out.println(doc);
30+
});
31+
}
32+
2433
@Test
2534
public void scriptDoc() throws Exception {
2635
withDoc(

modules/jooby-openapi/src/test/java/javadoc/PrintAstTree.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.io.IOException;
1010
import java.nio.file.Path;
1111
import java.nio.file.Paths;
12-
import javadoc.input.ScriptApp;
12+
import javadoc.input.LambdaRefApp;
1313

1414
import com.puppycrawl.tools.checkstyle.AstTreeStringPrinter;
1515
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
@@ -25,7 +25,7 @@ public static void main(String[] args) throws CheckstyleException, IOException {
2525
.resolve("java");
2626
var stringAst =
2727
AstTreeStringPrinter.printJavaAndJavadocTree(
28-
baseDir.resolve(toPath(ScriptApp.class)).toFile());
28+
baseDir.resolve(toPath(LambdaRefApp.class)).toFile());
2929
System.out.println(stringAst);
3030
}
3131

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Jooby https://jooby.io
3+
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
4+
* Copyright 2014 Edgar Espina
5+
*/
6+
package javadoc.input;
7+
8+
import edu.umd.cs.findbugs.annotations.NonNull;
9+
import io.jooby.Context;
10+
import io.jooby.Jooby;
11+
12+
public class LambdaRefApp extends Jooby {
13+
14+
{
15+
path(
16+
"/api/pets",
17+
() -> {
18+
get("/{id}", this::findPetById);
19+
});
20+
}
21+
22+
/*
23+
* Find pet by id.
24+
* @param id Pet ID.
25+
*/
26+
private @NonNull String findPetById(Context ctx) {
27+
var id = ctx.path("id").value();
28+
return "Pets";
29+
}
30+
}

0 commit comments

Comments
 (0)